1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This is a "No Compile Test" suite.
6 // http://dev.chromium.org/developers/testing/no-compile-tests
8 #include "base/callback_list.h"
13 #include "base/functional/bind.h"
14 #include "base/functional/callback_helpers.h"
26 FooListener() = default;
27 FooListener(const FooListener&) = delete;
28 FooListener& operator=(const FooListener&) = delete;
30 void GotAScopedFoo(std::unique_ptr<Foo> f) { foo_ = std::move(f); }
32 std::unique_ptr<Foo> foo_;
35 // Callbacks run with a move-only typed parameter.
37 // CallbackList does not support move-only typed parameters. Notify() is
38 // designed to take zero or more parameters, and run each registered callback
39 // with them. With move-only types, the parameter will be set to NULL after the
40 // first callback has been run.
43 RepeatingCallbackList<void(std::unique_ptr<Foo>)> c1;
44 CallbackListSubscription sub =
45 c1.Add(BindRepeating(&FooListener::GotAScopedFoo, Unretained(&f)));
46 c1.Notify(std::unique_ptr<Foo>(new Foo())); // expected-error@*:* {{call to implicitly-deleted copy constructor of 'std::unique_ptr<base::Foo>'}}