blob: fd83d02d6c67138f66dfd22e330ec5781a62be1c [file] [log] [blame]
[email protected]243576f2013-09-25 13:56:231// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
scheib0411d8f72015-10-19 19:29:555// This is a "No Compile Test" suite.
6// http://dev.chromium.org/developers/testing/no-compile-tests
7
[email protected]2a7cac02013-09-26 19:20:188#include "base/callback_list.h"
[email protected]243576f2013-09-25 13:56:239
10#include "base/basictypes.h"
11#include "base/bind.h"
12#include "base/bind_helpers.h"
avi9b6f42932015-12-26 22:15:1413#include "base/macros.h"
[email protected]243576f2013-09-25 13:56:2314#include "base/memory/scoped_ptr.h"
15
16namespace base {
17
18class Foo {
19 public:
20 Foo() {}
21 ~Foo() {}
22};
23
24class FooListener {
25 public:
26 FooListener() {}
27
28 void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = f.Pass(); }
29
30 scoped_ptr<Foo> foo_;
31
32 private:
33 DISALLOW_COPY_AND_ASSIGN(FooListener);
34};
35
36
tzik096369a2015-12-11 06:39:0637#if defined(NCTEST_MOVE_ONLY_TYPE_PARAMETER) // [r"fatal error: call to deleted constructor"]
[email protected]243576f2013-09-25 13:56:2338
39// Callbacks run with a move-only typed parameter.
40//
[email protected]2a7cac02013-09-26 19:20:1841// CallbackList does not support move-only typed parameters. Notify() is
[email protected]243576f2013-09-25 13:56:2342// designed to take zero or more parameters, and run each registered callback
43// with them. With move-only types, the parameter will be set to NULL after the
44// first callback has been run.
45void WontCompile() {
46 FooListener f;
[email protected]2a7cac02013-09-26 19:20:1847 CallbackList<void(scoped_ptr<Foo>)> c1;
48 scoped_ptr<CallbackList<void(scoped_ptr<Foo>)>::Subscription> sub =
[email protected]243576f2013-09-25 13:56:2349 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f)));
50 c1.Notify(scoped_ptr<Foo>(new Foo()));
51}
52
53#endif
54
55} // namespace base