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/template_util.h" | 5 #include "base/template_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 std::ostream& operator<<(std::ostream& os, const StructWithOperator& v) { | 23 std::ostream& operator<<(std::ostream& os, const StructWithOperator& v) { |
24 return os; | 24 return os; |
25 } | 25 } |
26 | 26 |
27 // is_non_const_reference<Type> | 27 // is_non_const_reference<Type> |
28 static_assert(!is_non_const_reference<int>::value, "IsNonConstReference"); | 28 static_assert(!is_non_const_reference<int>::value, "IsNonConstReference"); |
29 static_assert(!is_non_const_reference<const int&>::value, | 29 static_assert(!is_non_const_reference<const int&>::value, |
30 "IsNonConstReference"); | 30 "IsNonConstReference"); |
31 static_assert(is_non_const_reference<int&>::value, "IsNonConstReference"); | 31 static_assert(is_non_const_reference<int&>::value, "IsNonConstReference"); |
32 | 32 |
| 33 // underlying_number |
| 34 enum ClassicEnum : int { CLASSIC_ENUM_A }; |
| 35 enum class ClassyEnum : int { A }; |
| 36 |
| 37 static_assert( |
| 38 std::is_same<decltype(underlying_number(int64_t(10))), int64_t>::value, |
| 39 "underlying_number: failed to return an integer as its own type."); |
| 40 |
| 41 static_assert( |
| 42 std::is_integral<decltype(underlying_number(CLASSIC_ENUM_A))>::value, |
| 43 "underlying_number: failed to return an unscoped enum as an integer."); |
| 44 |
| 45 static_assert( |
| 46 std::is_integral<decltype(underlying_number(ClassyEnum::A))>::value, |
| 47 "underlying_number: failed to return a scoped enum as an integer."); |
| 48 |
33 class AssignParent {}; | 49 class AssignParent {}; |
34 class AssignChild : AssignParent {}; | 50 class AssignChild : AssignParent {}; |
35 | 51 |
36 // is_assignable<Type1, Type2> | 52 // is_assignable<Type1, Type2> |
37 static_assert(!is_assignable<int, int>::value, "IsAssignable"); // 1 = 1; | 53 static_assert(!is_assignable<int, int>::value, "IsAssignable"); // 1 = 1; |
38 static_assert(!is_assignable<int, double>::value, "IsAssignable"); | 54 static_assert(!is_assignable<int, double>::value, "IsAssignable"); |
39 static_assert(is_assignable<int&, int>::value, "IsAssignable"); | 55 static_assert(is_assignable<int&, int>::value, "IsAssignable"); |
40 static_assert(is_assignable<int&, double>::value, "IsAssignable"); | 56 static_assert(is_assignable<int&, double>::value, "IsAssignable"); |
41 static_assert(is_assignable<int&, int&>::value, "IsAssignable"); | 57 static_assert(is_assignable<int&, int&>::value, "IsAssignable"); |
42 static_assert(is_assignable<int&, int const&>::value, "IsAssignable"); | 58 static_assert(is_assignable<int&, int const&>::value, "IsAssignable"); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 }; | 136 }; |
121 | 137 |
122 static_assert(is_trivially_destructible<int>::value, "IsTriviallyDestructible"); | 138 static_assert(is_trivially_destructible<int>::value, "IsTriviallyDestructible"); |
123 static_assert(is_trivially_destructible<TriviallyDestructible>::value, | 139 static_assert(is_trivially_destructible<TriviallyDestructible>::value, |
124 "IsTriviallyDestructible"); | 140 "IsTriviallyDestructible"); |
125 static_assert(!is_trivially_destructible<NonTriviallyDestructible>::value, | 141 static_assert(!is_trivially_destructible<NonTriviallyDestructible>::value, |
126 "IsTriviallyDestructible"); | 142 "IsTriviallyDestructible"); |
127 | 143 |
128 } // namespace | 144 } // namespace |
129 } // namespace base | 145 } // namespace base |
OLD | NEW |