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 "base/containers/flat_tree.h" |
| 10 #include "base/test/move_only_int.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 | 12 |
11 namespace base { | 13 namespace base { |
12 namespace { | 14 namespace { |
13 | 15 |
14 enum SimpleEnum { SIMPLE_ENUM }; | 16 enum SimpleEnum { SIMPLE_ENUM }; |
15 enum EnumWithExplicitType : uint64_t { ENUM_WITH_EXPLICIT_TYPE }; | 17 enum EnumWithExplicitType : uint64_t { ENUM_WITH_EXPLICIT_TYPE }; |
16 enum class ScopedEnum { SCOPED_ENUM }; | 18 enum class ScopedEnum { SCOPED_ENUM }; |
17 enum class ScopedEnumWithOperator { SCOPED_ENUM_WITH_OPERATOR }; | 19 enum class ScopedEnumWithOperator { SCOPED_ENUM_WITH_OPERATOR }; |
18 std::ostream& operator<<(std::ostream& os, ScopedEnumWithOperator v) { | 20 std::ostream& operator<<(std::ostream& os, ScopedEnumWithOperator v) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 ~TrivialCopyButWithDestructor() { data_ = 0; } | 86 ~TrivialCopyButWithDestructor() { data_ = 0; } |
85 }; | 87 }; |
86 | 88 |
87 static_assert(base::is_trivially_copyable<TrivialCopy>::value, | 89 static_assert(base::is_trivially_copyable<TrivialCopy>::value, |
88 "TrivialCopy should be detected as trivially copyable"); | 90 "TrivialCopy should be detected as trivially copyable"); |
89 static_assert(!base::is_trivially_copyable<TrivialCopyButWithDestructor>::value, | 91 static_assert(!base::is_trivially_copyable<TrivialCopyButWithDestructor>::value, |
90 "TrivialCopyButWithDestructor should not be detected as " | 92 "TrivialCopyButWithDestructor should not be detected as " |
91 "trivially copyable"); | 93 "trivially copyable"); |
92 | 94 |
93 } // namespace | 95 } // namespace |
| 96 |
| 97 TEST(TemplateUtil, Less) { |
| 98 using ExplicitInt = base::MoveOnlyInt; |
| 99 EXPECT_TRUE(base::less()(ExplicitInt(3), 4)); |
| 100 EXPECT_FALSE(base::less()(4, ExplicitInt(3))); |
| 101 EXPECT_TRUE(base::less()(3, 4)); |
| 102 |
| 103 static_assert(base::internal::IsTransparentCompare<base::less>::value, ""); |
| 104 } |
| 105 |
94 } // namespace base | 106 } // namespace base |
OLD | NEW |