blob: 08acce68fd624a293645a49ad505c7a2d34e4b03 [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"
13#include "base/memory/scoped_ptr.h"
14
15namespace base {
16
17class Foo {
18 public:
19 Foo() {}
20 ~Foo() {}
21};
22
23class FooListener {
24 public:
25 FooListener() {}
26
27 void GotAScopedFoo(scoped_ptr<Foo> f) { foo_ = f.Pass(); }
28
29 scoped_ptr<Foo> foo_;
30
31 private:
32 DISALLOW_COPY_AND_ASSIGN(FooListener);
33};
34
35
36#if defined(NCTEST_MOVE_ONLY_TYPE_PARAMETER) // [r"calling a private constructor of class"]
37
38// Callbacks run with a move-only typed parameter.
39//
[email protected]2a7cac02013-09-26 19:20:1840// CallbackList does not support move-only typed parameters. Notify() is
[email protected]243576f2013-09-25 13:56:2341// 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
43// first callback has been run.
44void WontCompile() {
45 FooListener f;
[email protected]2a7cac02013-09-26 19:20:1846 CallbackList<void(scoped_ptr<Foo>)> c1;
47 scoped_ptr<CallbackList<void(scoped_ptr<Foo>)>::Subscription> sub =
[email protected]243576f2013-09-25 13:56:2348 c1.Add(Bind(&FooListener::GotAScopedFoo, Unretained(&f)));
49 c1.Notify(scoped_ptr<Foo>(new Foo()));
50}
51
52#endif
53
54} // namespace base