Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <memory> |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 | 28 |
| 29 void GotAScopedFoo(std::unique_ptr<Foo> f) { foo_ = std::move(f); } | 29 void GotAScopedFoo(std::unique_ptr<Foo> f) { foo_ = std::move(f); } |
| 30 | 30 |
| 31 std::unique_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 [^ ]*de leted .*constructor"] |
|
dcheng
2016/12/27 04:58:33
Can we make this match precise?
"call to (implicit
wychen
2016/12/27 09:49:51
Done.
| |
| 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(std::unique_ptr<Foo>)> c1; | 48 CallbackList<void(std::unique_ptr<Foo>)> c1; |
| 49 std::unique_ptr<CallbackList<void(std::unique_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(std::unique_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 |
| OLD | NEW |