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

Side by Side Diff: base/callback_list_unittest.nc

Issue 1556683003: Fix no-compile base_unittests for base::Pass() -> std::move conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unneeded std::move Created 4 years, 11 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 | « no previous file | base/memory/scoped_ptr_unittest.nc » ('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 <utility>
11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
14 16
15 namespace base { 17 namespace base {
16 18
17 class Foo { 19 class Foo {
18 public: 20 public:
19 Foo() {} 21 Foo() {}
20 ~Foo() {} 22 ~Foo() {}
21 }; 23 };
22 24
23 class FooListener { 25 class FooListener {
24 public: 26 public:
25 FooListener() {} 27 FooListener() {}
26 28
27 void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = f.Pass(); } 29 void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = std::move(f); }
28 30
29 scoped_ptr<Foo> foo_; 31 scoped_ptr<Foo> foo_;
30 32
31 private: 33 private:
32 DISALLOW_COPY_AND_ASSIGN(FooListener); 34 DISALLOW_COPY_AND_ASSIGN(FooListener);
33 }; 35 };
34 36
35 37
36 #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"]
37 39
38 // Callbacks run with a move-only typed parameter. 40 // Callbacks run with a move-only typed parameter.
39 // 41 //
40 // CallbackList does not support move-only typed parameters. Notify() is 42 // CallbackList does not support move-only typed parameters. Notify() is
41 // 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
42 // 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
43 // first callback has been run. 45 // first callback has been run.
44 void WontCompile() { 46 void WontCompile() {
45 FooListener f; 47 FooListener f;
46 CallbackList<void(scoped_ptr<Foo>)> c1; 48 CallbackList<void(scoped_ptr<Foo>)> c1;
47 scoped_ptr<CallbackList<void(scoped_ptr<Foo>)>::Subscription> sub = 49 scoped_ptr<CallbackList<void(scoped_ptr<Foo>)>::Subscription> sub =
48 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f))); 50 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f)));
49 c1.Notify(scoped_ptr<Foo>(new Foo())); 51 c1.Notify(scoped_ptr<Foo>(new Foo()));
50 } 52 }
51 53
52 #endif 54 #endif
53 55
54 } // namespace base 56 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/memory/scoped_ptr_unittest.nc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698