OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef BASE_TEMPLATE_UTIL_H_ | 5 #ifndef BASE_TEMPLATE_UTIL_H_ |
6 #define BASE_TEMPLATE_UTIL_H_ | 6 #define BASE_TEMPLATE_UTIL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <type_traits> | 10 #include <type_traits> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 template <typename T, typename = void> | 57 template <typename T, typename = void> |
58 struct SupportsOstreamOperator : std::false_type {}; | 58 struct SupportsOstreamOperator : std::false_type {}; |
59 template <typename T> | 59 template <typename T> |
60 struct SupportsOstreamOperator<T, | 60 struct SupportsOstreamOperator<T, |
61 decltype(void(std::declval<std::ostream&>() | 61 decltype(void(std::declval<std::ostream&>() |
62 << std::declval<T>()))> | 62 << std::declval<T>()))> |
63 : std::true_type {}; | 63 : std::true_type {}; |
64 | 64 |
65 } // namespace internal | 65 } // namespace internal |
66 | 66 |
67 // underlying_type produces the integer type backing an enum type. | |
68 // TODO(crbug.com/554293): Remove this when all platforms have this in the std | |
69 // namespace. | |
70 #if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX) | |
71 template <typename T> | |
72 struct underlying_type { | |
73 using type = __underlying_type(T); | |
74 }; | |
75 #else | |
76 template <typename T> | |
77 using underlying_type = std::underlying_type<T>; | |
78 #endif | |
79 | |
80 // TODO(crbug.com/554293): Remove this when all platforms have this in the std | 67 // TODO(crbug.com/554293): Remove this when all platforms have this in the std |
81 // namespace. | 68 // namespace. |
82 #if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX) | 69 #if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX) |
83 template <class T> | 70 template <class T> |
84 using is_trivially_destructible = std::has_trivial_destructor<T>; | 71 using is_trivially_destructible = std::has_trivial_destructor<T>; |
85 #else | 72 #else |
86 template <class T> | 73 template <class T> |
87 using is_trivially_destructible = std::is_trivially_destructible<T>; | 74 using is_trivially_destructible = std::is_trivially_destructible<T>; |
88 #endif | 75 #endif |
89 | 76 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 using is_trivially_copyable = std::is_trivially_copyable<T>; | 117 using is_trivially_copyable = std::is_trivially_copyable<T>; |
131 #endif | 118 #endif |
132 | 119 |
133 } // namespace base | 120 } // namespace base |
134 | 121 |
135 #undef CR_USE_FALLBACKS_FOR_OLD_GLIBCXX | 122 #undef CR_USE_FALLBACKS_FOR_OLD_GLIBCXX |
136 #undef CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX | 123 #undef CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX |
137 #undef CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX | 124 #undef CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX |
138 | 125 |
139 #endif // BASE_TEMPLATE_UTIL_H_ | 126 #endif // BASE_TEMPLATE_UTIL_H_ |
OLD | NEW |