Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: base/callback_list_unittest.nc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/callback_list_unittest.cc ('k') | base/callback_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is a "No Compile Test" suite. 5 // This is a "No Compile Test" suite.
6 // http://dev.chromium.org/developers/testing/no-compile-tests 6 // http://dev.chromium.org/developers/testing/no-compile-tests
7 7
8 #include "base/callback_list.h" 8 #include "base/callback_list.h"
9 9
10 #include <memory>
10 #include <utility> 11 #include <utility>
11 12
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 16
17 namespace base { 17 namespace base {
18 18
19 class Foo { 19 class Foo {
20 public: 20 public:
21 Foo() {} 21 Foo() {}
22 ~Foo() {} 22 ~Foo() {}
23 }; 23 };
24 24
25 class FooListener { 25 class FooListener {
26 public: 26 public:
27 FooListener() {} 27 FooListener() {}
28 28
29 void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = std::move(f); } 29 void GotAScopedFoo(std::unique_ptr<Foo> f) { foo_ = std::move(f); }
30 30
31 scoped_ptr<Foo> foo_; 31 std::unique_ptr<Foo> foo_;
32 32
33 private: 33 private:
34 DISALLOW_COPY_AND_ASSIGN(FooListener); 34 DISALLOW_COPY_AND_ASSIGN(FooListener);
35 }; 35 };
36 36
37 37
38 #if defined(NCTEST_MOVE_ONLY_TYPE_PARAMETER) // [r"fatal error: call to deleted constructor"] 38 #if defined(NCTEST_MOVE_ONLY_TYPE_PARAMETER) // [r"fatal error: call to deleted constructor"]
39 39
40 // Callbacks run with a move-only typed parameter. 40 // Callbacks run with a move-only typed parameter.
41 // 41 //
42 // CallbackList does not support move-only typed parameters. Notify() is 42 // CallbackList does not support move-only typed parameters. Notify() is
43 // designed to take zero or more parameters, and run each registered callback 43 // designed to take zero or more parameters, and run each registered callback
44 // with them. With move-only types, the parameter will be set to NULL after the 44 // with them. With move-only types, the parameter will be set to NULL after the
45 // first callback has been run. 45 // first callback has been run.
46 void WontCompile() { 46 void WontCompile() {
47 FooListener f; 47 FooListener f;
48 CallbackList<void(scoped_ptr<Foo>)> c1; 48 CallbackList<void(std::unique_ptr<Foo>)> c1;
49 scoped_ptr<CallbackList<void(scoped_ptr<Foo>)>::Subscription> sub = 49 std::unique_ptr<CallbackList<void(std::unique_ptr<Foo>)>::Subscription> sub =
50 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f))); 50 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f)));
51 c1.Notify(scoped_ptr<Foo>(new Foo())); 51 c1.Notify(std::unique_ptr<Foo>(new Foo()));
52 } 52 }
53 53
54 #endif 54 #endif
55 55
56 } // namespace base 56 } // namespace base
OLDNEW
« no previous file with comments | « base/callback_list_unittest.cc ('k') | base/callback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698