[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 1 | // Copyright (c) 2011 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 | |
scheib | 0411d8f7 | 2015-10-19 19:29:55 | [diff] [blame] | 5 | // This is a "No Compile Test" suite. |
| 6 | // http://dev.chromium.org/developers/testing/no-compile-tests |
| 7 | |
dcheng | 172b6ad | 2016-09-24 05:05:57 | [diff] [blame] | 8 | #include <utility> |
| 9 | |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 10 | #include "base/bind.h" |
avi | 9b6f4293 | 2015-12-26 22:15:14 | [diff] [blame] | 11 | #include "base/callback.h" |
| 12 | #include "base/macros.h" |
[email protected] | 7296f276 | 2011-11-21 19:23:44 | [diff] [blame] | 13 | #include "base/memory/ref_counted.h" |
tzik | f98654b | 2017-12-02 03:28:58 | [diff] [blame] | 14 | #include "base/test/bind_test_util.h" |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 15 | |
| 16 | namespace base { |
| 17 | |
| 18 | // Do not put everything inside an anonymous namespace. If you do, many of the |
[email protected] | 5dd6bdf | 2014-02-21 16:24:13 | [diff] [blame] | 19 | // helper function declarations will generate unused definition warnings. |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 20 | |
| 21 | static const int kParentValue = 1; |
| 22 | static const int kChildValue = 2; |
| 23 | |
| 24 | class NoRef { |
| 25 | public: |
| 26 | void VoidMethod0() {} |
| 27 | void VoidConstMethod0() const {} |
| 28 | int IntMethod0() { return 1; } |
| 29 | }; |
| 30 | |
[email protected] | 7296f276 | 2011-11-21 19:23:44 | [diff] [blame] | 31 | class HasRef : public NoRef, public base::RefCounted<HasRef> { |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | class Parent { |
| 35 | public: |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 36 | void AddRef() const {} |
| 37 | void Release() const {} |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 38 | virtual void VirtualSet() { value = kParentValue; } |
| 39 | void NonVirtualSet() { value = kParentValue; } |
| 40 | int value; |
| 41 | }; |
| 42 | |
| 43 | class Child : public Parent { |
| 44 | public: |
| 45 | virtual void VirtualSet() { value = kChildValue; } |
| 46 | void NonVirtualSet() { value = kChildValue; } |
| 47 | }; |
| 48 | |
| 49 | class NoRefParent { |
| 50 | public: |
| 51 | virtual void VirtualSet() { value = kParentValue; } |
| 52 | void NonVirtualSet() { value = kParentValue; } |
| 53 | int value; |
| 54 | }; |
| 55 | |
| 56 | class NoRefChild : public NoRefParent { |
| 57 | virtual void VirtualSet() { value = kChildValue; } |
| 58 | void NonVirtualSet() { value = kChildValue; } |
| 59 | }; |
| 60 | |
| 61 | template <typename T> |
| 62 | T PolymorphicIdentity(T t) { |
| 63 | return t; |
| 64 | } |
| 65 | |
| 66 | int UnwrapParentRef(Parent& p) { |
| 67 | return p.value; |
| 68 | } |
| 69 | |
| 70 | template <typename T> |
| 71 | void VoidPolymorphic1(T t) { |
| 72 | } |
| 73 | |
Daniel Cheng | a09cb60 | 2017-08-30 13:46:19 | [diff] [blame] | 74 | void TakesMoveOnly(std::unique_ptr<int>) { |
| 75 | } |
| 76 | |
tzik | f98654b | 2017-12-02 03:28:58 | [diff] [blame] | 77 | struct NonEmptyFunctor { |
| 78 | int x; |
| 79 | void operator()() const {} |
| 80 | }; |
| 81 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 82 | // TODO(hans): Remove .* and update the static_assert expectations once we roll |
| 83 | // past Clang r313315. https://crbug.com/765692. |
| 84 | |
| 85 | #if defined(NCTEST_METHOD_ON_CONST_OBJECT) // [r"fatal error: static_assert failed .*\"Bound argument \|i\| of type \|Arg\| cannot be forwarded as \|Unwrapped\| to the bound functor, which declares it as \|Param\|\.\""] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 86 | |
| 87 | // Method bound to const-object. |
| 88 | // |
| 89 | // Only const methods should be allowed to work with const objects. |
| 90 | void WontCompile() { |
| 91 | HasRef has_ref; |
| 92 | const HasRef* const_has_ref_ptr_ = &has_ref; |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 93 | Callback<void()> method_to_const_cb = |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 94 | Bind(&HasRef::VoidMethod0, const_has_ref_ptr_); |
| 95 | method_to_const_cb.Run(); |
| 96 | } |
| 97 | |
tzik | 4625ac61 | 2018-02-28 09:43:55 | [diff] [blame] | 98 | #elif defined(NCTEST_METHOD_BIND_NEEDS_REFCOUNTED_OBJECT) // [r"fatal error: static_assert failed \"Receivers may not be raw pointers\."] |
| 99 | |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 100 | |
| 101 | // Method bound to non-refcounted object. |
| 102 | // |
| 103 | // We require refcounts unless you have Unretained(). |
| 104 | void WontCompile() { |
| 105 | NoRef no_ref; |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 106 | Callback<void()> no_ref_cb = |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 107 | Bind(&NoRef::VoidMethod0, &no_ref); |
| 108 | no_ref_cb.Run(); |
| 109 | } |
| 110 | |
tzik | 4625ac61 | 2018-02-28 09:43:55 | [diff] [blame] | 111 | #elif defined(NCTEST_CONST_METHOD_NEEDS_REFCOUNTED_OBJECT) // [r"fatal error: static_assert failed \"Receivers may not be raw pointers\."] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 112 | |
| 113 | // Const Method bound to non-refcounted object. |
| 114 | // |
| 115 | // We require refcounts unless you have Unretained(). |
| 116 | void WontCompile() { |
| 117 | NoRef no_ref; |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 118 | Callback<void()> no_ref_const_cb = |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 119 | Bind(&NoRef::VoidConstMethod0, &no_ref); |
| 120 | no_ref_const_cb.Run(); |
| 121 | } |
| 122 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 123 | #elif defined(NCTEST_CONST_POINTER) // [r"fatal error: static_assert failed .*\"Bound argument \|i\| of type \|Arg\| cannot be forwarded as \|Unwrapped\| to the bound functor, which declares it as \|Param\|\.\""] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 124 | |
| 125 | // Const argument used with non-const pointer parameter of same type. |
| 126 | // |
| 127 | // This is just a const-correctness check. |
| 128 | void WontCompile() { |
| 129 | const NoRef* const_no_ref_ptr; |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 130 | Callback<NoRef*()> pointer_same_cb = |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 131 | Bind(&PolymorphicIdentity<NoRef*>, const_no_ref_ptr); |
| 132 | pointer_same_cb.Run(); |
| 133 | } |
| 134 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 135 | #elif defined(NCTEST_CONST_POINTER_SUBTYPE) // [r"fatal error: static_assert failed .*\"Bound argument \|i\| of type \|Arg\| cannot be forwarded as \|Unwrapped\| to the bound functor, which declares it as \|Param\|\.\""] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 136 | |
| 137 | // Const argument used with non-const pointer parameter of super type. |
| 138 | // |
| 139 | // This is just a const-correctness check. |
| 140 | void WontCompile() { |
| 141 | const NoRefChild* const_child_ptr; |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 142 | Callback<NoRefParent*()> pointer_super_cb = |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 143 | Bind(&PolymorphicIdentity<NoRefParent*>, const_child_ptr); |
| 144 | pointer_super_cb.Run(); |
| 145 | } |
| 146 | |
dcheng | b760d72 | 2014-11-03 21:29:30 | [diff] [blame] | 147 | #elif defined(DISABLED_NCTEST_DISALLOW_NON_CONST_REF_PARAM) // [r"fatal error: no member named 'AddRef' in 'base::NoRef'"] |
| 148 | // TODO(dcheng): I think there's a type safety promotion issue here where we can |
| 149 | // pass a const ref to a non const-ref function, or vice versa accidentally. Or |
| 150 | // we make a copy accidentally. Check. |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 151 | |
| 152 | // Functions with reference parameters, unsupported. |
| 153 | // |
| 154 | // First, non-const reference parameters are disallowed by the Google |
| 155 | // style guide. Second, since we are doing argument forwarding it becomes |
| 156 | // very tricky to avoid copies, maintain const correctness, and not |
| 157 | // accidentally have the function be modifying a temporary, or a copy. |
| 158 | void WontCompile() { |
| 159 | Parent p; |
| 160 | Callback<int(Parent&)> ref_arg_cb = Bind(&UnwrapParentRef); |
| 161 | ref_arg_cb.Run(p); |
| 162 | } |
| 163 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 164 | #elif defined(NCTEST_DISALLOW_BIND_TO_NON_CONST_REF_PARAM) // [r"fatal error: static_assert failed .*\"Bound argument \|i\| of type \|Arg\| cannot be forwarded as \|Unwrapped\| to the bound functor, which declares it as \|Param\|\.\""] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 165 | |
| 166 | // Binding functions with reference parameters, unsupported. |
| 167 | // |
| 168 | // See comment in NCTEST_DISALLOW_NON_CONST_REF_PARAM |
| 169 | void WontCompile() { |
| 170 | Parent p; |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 171 | Callback<int()> ref_cb = Bind(&UnwrapParentRef, p); |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 172 | ref_cb.Run(); |
| 173 | } |
| 174 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 175 | #elif defined(NCTEST_NO_IMPLICIT_ARRAY_PTR_CONVERSION) // [r"fatal error: static_assert failed .*\"First bound argument to a method cannot be an array\.\""] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 176 | |
| 177 | // A method should not be bindable with an array of objects. |
| 178 | // |
| 179 | // This is likely not wanted behavior. We specifically check for it though |
| 180 | // because it is possible, depending on how you implement prebinding, to |
| 181 | // implicitly convert an array type to a pointer type. |
| 182 | void WontCompile() { |
| 183 | HasRef p[10]; |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 184 | Callback<void()> method_bound_to_array_cb = |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 185 | Bind(&HasRef::VoidMethod0, p); |
| 186 | method_bound_to_array_cb.Run(); |
| 187 | } |
| 188 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 189 | #elif defined(NCTEST_NO_RVALUE_RAW_PTR_FOR_REFCOUNTED_TYPES) // [r"fatal error: static_assert failed .*\"A parameter is a refcounted type and needs scoped_refptr\.\""] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 190 | |
| 191 | // Refcounted types should not be bound as a raw pointer. |
| 192 | void WontCompile() { |
| 193 | HasRef for_raw_ptr; |
[email protected] | 7296f276 | 2011-11-21 19:23:44 | [diff] [blame] | 194 | int a; |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 195 | Callback<void()> ref_count_as_raw_ptr_a = |
[email protected] | 7296f276 | 2011-11-21 19:23:44 | [diff] [blame] | 196 | Bind(&VoidPolymorphic1<int*>, &a); |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 197 | Callback<void()> ref_count_as_raw_ptr = |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 198 | Bind(&VoidPolymorphic1<HasRef*>, &for_raw_ptr); |
| 199 | } |
| 200 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 201 | #elif defined(NCTEST_NO_LVALUE_RAW_PTR_FOR_REFCOUNTED_TYPES) // [r"fatal error: static_assert failed .*\"A parameter is a refcounted type and needs scoped_refptr\.\""] |
tzik | 1d692a2e | 2017-07-03 11:01:26 | [diff] [blame] | 202 | |
| 203 | // Refcounted types should not be bound as a raw pointer. |
| 204 | void WontCompile() { |
| 205 | HasRef* for_raw_ptr = nullptr; |
| 206 | Callback<void()> ref_count_as_raw_ptr = |
| 207 | Bind(&VoidPolymorphic1<HasRef*>, for_raw_ptr); |
| 208 | } |
| 209 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 210 | #elif defined(NCTEST_NO_RVALUE_CONST_RAW_PTR_FOR_REFCOUNTED_TYPES) // [r"fatal error: static_assert failed .*\"A parameter is a refcounted type and needs scoped_refptr\.\""] |
tzik | f41b933 | 2017-07-10 09:13:33 | [diff] [blame] | 211 | |
| 212 | // Refcounted types should not be bound as a raw pointer. |
| 213 | void WontCompile() { |
| 214 | const HasRef for_raw_ptr; |
| 215 | Callback<void()> ref_count_as_raw_ptr = |
| 216 | Bind(&VoidPolymorphic1<const HasRef*>, &for_raw_ptr); |
| 217 | } |
| 218 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 219 | #elif defined(NCTEST_NO_LVALUE_CONST_RAW_PTR_FOR_REFCOUNTED_TYPES) // [r"fatal error: static_assert failed .*\"A parameter is a refcounted type and needs scoped_refptr\.\""] |
tzik | f41b933 | 2017-07-10 09:13:33 | [diff] [blame] | 220 | |
| 221 | // Refcounted types should not be bound as a raw pointer. |
| 222 | void WontCompile() { |
| 223 | const HasRef* for_raw_ptr = nullptr; |
| 224 | Callback<void()> ref_count_as_raw_ptr = |
| 225 | Bind(&VoidPolymorphic1<const HasRef*>, for_raw_ptr); |
| 226 | } |
| 227 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 228 | #elif defined(NCTEST_WEAKPTR_BIND_MUST_RETURN_VOID) // [r"fatal error: static_assert failed .*\"weak_ptrs can only bind to methods without return values\""] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 229 | |
| 230 | // WeakPtrs cannot be bound to methods with return types. |
| 231 | void WontCompile() { |
| 232 | NoRef no_ref; |
| 233 | WeakPtrFactory<NoRef> weak_factory(&no_ref); |
tzik | 3bc7779b | 2015-12-19 09:18:46 | [diff] [blame] | 234 | Callback<int()> weak_ptr_with_non_void_return_type = |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 235 | Bind(&NoRef::IntMethod0, weak_factory.GetWeakPtr()); |
| 236 | weak_ptr_with_non_void_return_type.Run(); |
| 237 | } |
| 238 | |
tzik | daa4f5a | 2016-02-12 13:54:37 | [diff] [blame] | 239 | #elif defined(NCTEST_DISALLOW_ASSIGN_DIFFERENT_TYPES) // [r"fatal error: no viable conversion from 'Callback<MakeUnboundRunType<void \(\*\)\(int\)>>' to 'Callback<void \(\)>'"] |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 240 | |
| 241 | // Bind result cannot be assigned to Callbacks with a mismatching type. |
| 242 | void WontCompile() { |
| 243 | Closure callback_mismatches_bind_type = Bind(&VoidPolymorphic1<int>); |
| 244 | } |
| 245 | |
wychen | 58b75f59 | 2016-12-23 07:08:44 | [diff] [blame] | 246 | #elif defined(NCTEST_DISALLOW_CAPTURING_LAMBDA) // [r"fatal error: implicit instantiation of undefined template 'base::internal::FunctorTraits<\(lambda at (\.\./)+base/bind_unittest.nc:[0-9]+:[0-9]+\), void>'"] |
tzik | c1db7265 | 2016-07-08 09:42:38 | [diff] [blame] | 247 | |
| 248 | void WontCompile() { |
wychen | 7525a84 | 2017-02-25 00:14:32 | [diff] [blame] | 249 | int i = 0, j = 0; |
| 250 | Bind([i,&j]() {j = i;}); |
tzik | c1db7265 | 2016-07-08 09:42:38 | [diff] [blame] | 251 | } |
| 252 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 253 | #elif defined(NCTEST_DISALLOW_ONCECALLBACK_RUN_ON_LVALUE) // [r"static_assert failed .*\"OnceCallback::Run\(\) may only be invoked on a non-const rvalue, i\.e\. std::move\(callback\)\.Run\(\)\.\""] |
dcheng | 77172b9 | 2016-11-22 07:46:06 | [diff] [blame] | 254 | |
| 255 | void WontCompile() { |
| 256 | OnceClosure cb = Bind([] {}); |
| 257 | cb.Run(); |
| 258 | } |
| 259 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 260 | #elif defined(NCTEST_DISALLOW_ONCECALLBACK_RUN_ON_CONST_LVALUE) // [r"static_assert failed .*\"OnceCallback::Run\(\) may only be invoked on a non-const rvalue, i\.e\. std::move\(callback\)\.Run\(\)\.\""] |
dcheng | 3f2fd66e | 2016-12-20 23:56:59 | [diff] [blame] | 261 | |
| 262 | void WontCompile() { |
| 263 | const OnceClosure cb = Bind([] {}); |
| 264 | cb.Run(); |
| 265 | } |
| 266 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 267 | #elif defined(NCTEST_DISALLOW_ONCECALLBACK_RUN_ON_CONST_RVALUE) // [r"static_assert failed .*\"OnceCallback::Run\(\) may only be invoked on a non-const rvalue, i\.e\. std::move\(callback\)\.Run\(\)\.\""] |
dcheng | 3f2fd66e | 2016-12-20 23:56:59 | [diff] [blame] | 268 | |
| 269 | void WontCompile() { |
| 270 | const OnceClosure cb = Bind([] {}); |
| 271 | std::move(cb).Run(); |
| 272 | } |
| 273 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 274 | #elif defined(NCTEST_DISALLOW_BIND_ONCECALLBACK) // [r"fatal error: static_assert failed .*\"BindRepeating cannot bind OnceCallback. Use BindOnce with std::move\(\)\.\""] |
tzik | ae4202e | 2017-07-31 10:41:54 | [diff] [blame] | 275 | |
| 276 | void WontCompile() { |
| 277 | Bind(BindOnce([](int) {}), 42); |
| 278 | } |
| 279 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 280 | #elif defined(NCTEST_DISALLOW_BINDONCE_LVALUE_ONCECALLBACK) // [r"fatal error: static_assert failed .*\"BindOnce requires non-const rvalue for OnceCallback binding\."] |
tzik | ae4202e | 2017-07-31 10:41:54 | [diff] [blame] | 281 | void WontCompile() { |
| 282 | auto cb = BindOnce([](int) {}); |
| 283 | BindOnce(cb, 42); |
| 284 | } |
| 285 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 286 | #elif defined(NCTEST_DISALLOW_BINDONCE_RVALUE_CONST_ONCECALLBACK) // [r"fatal error: static_assert failed .*\"BindOnce requires non-const rvalue for OnceCallback binding\."] |
tzik | ae4202e | 2017-07-31 10:41:54 | [diff] [blame] | 287 | |
| 288 | void WontCompile() { |
| 289 | const auto cb = BindOnce([](int) {}); |
| 290 | BindOnce(std::move(cb), 42); |
| 291 | } |
| 292 | |
Hans Wennborg | 8023548 | 2017-09-15 18:34:51 | [diff] [blame] | 293 | #elif defined(NCTEST_BINDONCE_MOVEONLY_TYPE_BY_VALUE) // [r"fatal error: static_assert failed .*\"Bound argument \|i\| is move-only but will be bound by copy\. Ensure \|Arg\| is mutable and bound using std::move\(\)\.\""] |
Daniel Cheng | a09cb60 | 2017-08-30 13:46:19 | [diff] [blame] | 294 | |
| 295 | void WontCompile() { |
| 296 | std::unique_ptr<int> x; |
| 297 | BindOnce(&TakesMoveOnly, x); |
| 298 | } |
| 299 | |
| 300 | #elif defined(NCTEST_BIND_MOVEONLY_TYPE_BY_VALUE) // [r"Bound argument \|i\| is move-only but will be forwarded by copy\. Ensure \|Arg\| is bound using base::Passed\(\), not std::move\(\)."] |
| 301 | |
| 302 | void WontCompile() { |
| 303 | std::unique_ptr<int> x; |
| 304 | Bind(&TakesMoveOnly, x); |
| 305 | } |
| 306 | |
| 307 | #elif defined(NCTEST_BIND_MOVEONLY_TYPE_WITH_STDMOVE) // [r"Bound argument \|i\| is move-only but will be forwarded by copy\. Ensure \|Arg\| is bound using base::Passed\(\), not std::move\(\)."] |
| 308 | |
| 309 | void WontCompile() { |
| 310 | std::unique_ptr<int> x; |
| 311 | Bind(&TakesMoveOnly, std::move(x)); |
| 312 | } |
| 313 | |
tzik | f98654b | 2017-12-02 03:28:58 | [diff] [blame] | 314 | #elif defined(NCTEST_BIND_NON_EMPTY_FUNCTOR) // [r"fatal error: implicit instantiation of undefined template 'base::internal::FunctorTraits<base::NonEmptyFunctor, void>'"] |
| 315 | |
| 316 | void WontCompile() { |
| 317 | Bind(NonEmptyFunctor()); |
| 318 | } |
Daniel Cheng | a09cb60 | 2017-08-30 13:46:19 | [diff] [blame] | 319 | |
[email protected] | 81814bce | 2011-09-10 03:03:00 | [diff] [blame] | 320 | #endif |
| 321 | |
| 322 | } // namespace base |