Chromium Code Reviews| Index: base/template_util.h |
| diff --git a/base/template_util.h b/base/template_util.h |
| index 74c8e5afdc63dfb63f25922fc62835d854a8d48b..fbff1f14d8bc2ade67ac72c3bef258fbd6badafc 100644 |
| --- a/base/template_util.h |
| +++ b/base/template_util.h |
| @@ -11,6 +11,26 @@ |
| #include "build/build_config.h" |
| +// libc++ uses namespace std { inline namespace <libc++-version> { } } |
| +// so redeclaration in namespace std does not work. |
| +#ifdef _LIBCPP_BEGIN_NAMESPACE_STD |
| +_LIBCPP_BEGIN_NAMESPACE_STD |
| +#else |
| +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
|
| +#endif // _LIBCPP_BEGIN_NAMESPACE_STD |
| + |
| +template <class T> |
| +struct is_trivially_destructible; |
| + |
| +template <class T> |
| +struct has_trivial_destructor; |
| + |
| +#ifdef _LIBCPP_END_NAMESPACE_STD |
| +_LIBCPP_END_NAMESPACE_STD |
| +#else |
| +} // namespace std |
| +#endif // _LIBCPP_END_NAMESPACE_STD |
| + |
| namespace base { |
| template <class T> struct is_non_const_reference : std::false_type {}; |
| @@ -82,6 +102,36 @@ struct is_move_assignable |
| const typename std::add_rvalue_reference<T>::type> { |
| }; |
| +// is_trivially_destructible |
| + |
| +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
|
| + |
| +// From C++17. |
| +template <typename... Ts> |
| +struct make_void { |
| + typedef void type; |
| +}; |
| + |
| +template <typename... Ts> |
| +using void_t = typename make_void<Ts...>::type; |
| + |
| +template <class T, class = void> |
| +struct IsTriviallyDestructibleImpl : public std::has_trivial_destructor<T> {}; |
| + |
| +template <class T> |
| +struct IsTriviallyDestructibleImpl< |
| + T, |
| + void_t<typename std::is_trivially_destructible<T>::type>> |
| + : public std::is_trivially_destructible<T> {}; |
| + |
| +} // namespace internal |
| + |
| +// TODO(crbug.com/554293): Remove this when all platforms have this in the std |
| +// namespace. |
| +template <class T> |
| +struct is_trivially_destructible |
| + : public internal::IsTriviallyDestructibleImpl<T> {}; |
| + |
| } // namespace base |
| #endif // BASE_TEMPLATE_UTIL_H_ |