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 <type_traits> | 9 #include <type_traits> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 | 13 |
14 // libc++ uses namespace std { inline namespace <libc++-version> { } } | |
15 // so redeclaration in namespace std does not work. | |
16 #ifdef _LIBCPP_BEGIN_NAMESPACE_STD | |
17 _LIBCPP_BEGIN_NAMESPACE_STD | |
18 #else | |
19 namespace std { | |
Nico
2016/05/25 13:56:59
defining stuff in namespace std in user code has u
alshabalin
2016/05/26 09:18:46
Done. Removed in favor of macro from https://coder
| |
20 #endif // _LIBCPP_BEGIN_NAMESPACE_STD | |
21 | |
22 template <class T> | |
23 struct is_trivially_destructible; | |
24 | |
25 template <class T> | |
26 struct has_trivial_destructor; | |
27 | |
28 #ifdef _LIBCPP_END_NAMESPACE_STD | |
29 _LIBCPP_END_NAMESPACE_STD | |
30 #else | |
31 } // namespace std | |
32 #endif // _LIBCPP_END_NAMESPACE_STD | |
33 | |
14 namespace base { | 34 namespace base { |
15 | 35 |
16 template <class T> struct is_non_const_reference : std::false_type {}; | 36 template <class T> struct is_non_const_reference : std::false_type {}; |
17 template <class T> struct is_non_const_reference<T&> : std::true_type {}; | 37 template <class T> struct is_non_const_reference<T&> : std::true_type {}; |
18 template <class T> struct is_non_const_reference<const T&> : std::false_type {}; | 38 template <class T> struct is_non_const_reference<const T&> : std::false_type {}; |
19 | 39 |
20 // is_assignable | 40 // is_assignable |
21 | 41 |
22 namespace internal { | 42 namespace internal { |
23 | 43 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 | 95 |
76 // is_move_assignable is true if a T&& is assignable to a T&. | 96 // is_move_assignable is true if a T&& is assignable to a T&. |
77 // TODO(crbug.com/554293): Remove this when all platforms have this in the std | 97 // TODO(crbug.com/554293): Remove this when all platforms have this in the std |
78 // namespace. | 98 // namespace. |
79 template <class T> | 99 template <class T> |
80 struct is_move_assignable | 100 struct is_move_assignable |
81 : public is_assignable<typename std::add_lvalue_reference<T>::type, | 101 : public is_assignable<typename std::add_lvalue_reference<T>::type, |
82 const typename std::add_rvalue_reference<T>::type> { | 102 const typename std::add_rvalue_reference<T>::type> { |
83 }; | 103 }; |
84 | 104 |
105 // is_trivially_destructible | |
106 | |
107 namespace internal { | |
danakj
2016/05/25 20:02:09
Sorry I've been thinking about how to do this in a
alshabalin
2016/05/26 09:18:46
Done. Defined a macro CR_USE_FALLBACKS_FOR_OLD_GLI
| |
108 | |
109 // From C++17. | |
110 template <typename... Ts> | |
111 struct make_void { | |
112 typedef void type; | |
113 }; | |
114 | |
115 template <typename... Ts> | |
116 using void_t = typename make_void<Ts...>::type; | |
117 | |
118 template <class T, class = void> | |
119 struct IsTriviallyDestructibleImpl : public std::has_trivial_destructor<T> {}; | |
120 | |
121 template <class T> | |
122 struct IsTriviallyDestructibleImpl< | |
123 T, | |
124 void_t<typename std::is_trivially_destructible<T>::type>> | |
125 : public std::is_trivially_destructible<T> {}; | |
126 | |
127 } // namespace internal | |
128 | |
129 // TODO(crbug.com/554293): Remove this when all platforms have this in the std | |
130 // namespace. | |
131 template <class T> | |
132 struct is_trivially_destructible | |
133 : public internal::IsTriviallyDestructibleImpl<T> {}; | |
134 | |
85 } // namespace base | 135 } // namespace base |
86 | 136 |
87 #endif // BASE_TEMPLATE_UTIL_H_ | 137 #endif // BASE_TEMPLATE_UTIL_H_ |
OLD | NEW |