| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 | 1309 |
| 1310 // Move constructor and assignment of RepeatingCallback. | 1310 // Move constructor and assignment of RepeatingCallback. |
| 1311 static_assert(std::is_constructible< | 1311 static_assert(std::is_constructible< |
| 1312 RepeatingClosure, RepeatingClosure&&>::value, | 1312 RepeatingClosure, RepeatingClosure&&>::value, |
| 1313 "RepeatingClosure should be movable."); | 1313 "RepeatingClosure should be movable."); |
| 1314 static_assert(is_assignable< | 1314 static_assert(is_assignable< |
| 1315 RepeatingClosure, RepeatingClosure&&>::value, | 1315 RepeatingClosure, RepeatingClosure&&>::value, |
| 1316 "RepeatingClosure should be move-assignable"); | 1316 "RepeatingClosure should be move-assignable"); |
| 1317 | 1317 |
| 1318 // Conversions from OnceCallback to RepeatingCallback. | 1318 // Conversions from OnceCallback to RepeatingCallback. |
| 1319 #if !defined(COMPILER_MSVC) || defined(__clang__) |
| 1320 // In theory, this should have been fixed in VS2015 update 2: |
| 1321 // https://connect.microsoft.com/VisualStudio/feedback/details/819202 |
| 1319 static_assert(!std::is_constructible< | 1322 static_assert(!std::is_constructible< |
| 1320 RepeatingClosure, const OnceClosure&>::value, | 1323 RepeatingClosure, const OnceClosure&>::value, |
| 1321 "OnceClosure should not be convertible to RepeatingClosure."); | 1324 "OnceClosure should not be convertible to RepeatingClosure."); |
| 1322 static_assert(!is_assignable< | 1325 static_assert(!is_assignable< |
| 1323 RepeatingClosure, const OnceClosure&>::value, | 1326 RepeatingClosure, const OnceClosure&>::value, |
| 1324 "OnceClosure should not be convertible to RepeatingClosure."); | 1327 "OnceClosure should not be convertible to RepeatingClosure."); |
| 1325 | 1328 |
| 1326 // Destructive conversions from OnceCallback to RepeatingCallback. | 1329 // Destructive conversions from OnceCallback to RepeatingCallback. |
| 1327 static_assert(!std::is_constructible< | 1330 static_assert(!std::is_constructible< |
| 1328 RepeatingClosure, OnceClosure&&>::value, | 1331 RepeatingClosure, OnceClosure&&>::value, |
| 1329 "OnceClosure should not be convertible to RepeatingClosure."); | 1332 "OnceClosure should not be convertible to RepeatingClosure."); |
| 1330 static_assert(!is_assignable< | 1333 static_assert(!is_assignable< |
| 1331 RepeatingClosure, OnceClosure&&>::value, | 1334 RepeatingClosure, OnceClosure&&>::value, |
| 1332 "OnceClosure should not be convertible to RepeatingClosure."); | 1335 "OnceClosure should not be convertible to RepeatingClosure."); |
| 1336 #endif |
| 1333 | 1337 |
| 1334 // Copy constructor and assignment of OnceCallback. | 1338 // Copy constructor and assignment of OnceCallback. |
| 1335 static_assert(!std::is_constructible< | 1339 static_assert(!std::is_constructible< |
| 1336 OnceClosure, const OnceClosure&>::value, | 1340 OnceClosure, const OnceClosure&>::value, |
| 1337 "OnceClosure should not be copyable."); | 1341 "OnceClosure should not be copyable."); |
| 1338 static_assert(!is_assignable< | 1342 static_assert(!is_assignable< |
| 1339 OnceClosure, const OnceClosure&>::value, | 1343 OnceClosure, const OnceClosure&>::value, |
| 1340 "OnceClosure should not be copy-assignable"); | 1344 "OnceClosure should not be copy-assignable"); |
| 1341 | 1345 |
| 1342 // Move constructor and assignment of OnceCallback. | 1346 // Move constructor and assignment of OnceCallback. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 | 1414 |
| 1411 // Test null callbacks cause a DCHECK. | 1415 // Test null callbacks cause a DCHECK. |
| 1412 TEST(BindDeathTest, NullCallback) { | 1416 TEST(BindDeathTest, NullCallback) { |
| 1413 base::Callback<void(int)> null_cb; | 1417 base::Callback<void(int)> null_cb; |
| 1414 ASSERT_TRUE(null_cb.is_null()); | 1418 ASSERT_TRUE(null_cb.is_null()); |
| 1415 EXPECT_DCHECK_DEATH(base::Bind(null_cb, 42)); | 1419 EXPECT_DCHECK_DEATH(base::Bind(null_cb, 42)); |
| 1416 } | 1420 } |
| 1417 | 1421 |
| 1418 } // namespace | 1422 } // namespace |
| 1419 } // namespace base | 1423 } // namespace base |
| OLD | NEW |