diff options
Diffstat (limited to 'contrib/libc++/include/type_traits')
-rw-r--r-- | contrib/libc++/include/type_traits | 95 |
1 files changed, 74 insertions, 21 deletions
diff --git a/contrib/libc++/include/type_traits b/contrib/libc++/include/type_traits index 7862955..9db4d66 100644 --- a/contrib/libc++/include/type_traits +++ b/contrib/libc++/include/type_traits @@ -97,6 +97,7 @@ namespace std template <class T> struct is_polymorphic; template <class T> struct is_abstract; template <class T> struct is_final; // C++14 + template <class T> struct is_aggregate; // C++17 template <class T, class... Args> struct is_constructible; template <class T> struct is_default_constructible; @@ -286,6 +287,8 @@ namespace std = is_abstract<T>::value; // C++17 template <class T> constexpr bool is_final_v = is_final<T>::value; // C++17 + template <class T> constexpr bool is_aggregate_v + = is_aggregate<T>::value; // C++17 template <class T> constexpr bool is_signed_v = is_signed<T>::value; // C++17 template <class T> constexpr bool is_unsigned_v @@ -1272,11 +1275,13 @@ template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_T // decay -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS decay -{ -private: - typedef typename remove_reference<_Tp>::type _Up; +template <class _Up, bool> +struct __decay { + typedef typename remove_cv<_Up>::type type; +}; + +template <class _Up> +struct __decay<_Up, true> { public: typedef typename conditional < @@ -1291,24 +1296,23 @@ public: >::type type; }; +template <class _Tp> +struct _LIBCPP_TEMPLATE_VIS decay +{ +private: + typedef typename remove_reference<_Tp>::type _Up; +public: + typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type; +}; + #if _LIBCPP_STD_VER > 11 template <class _Tp> using decay_t = typename decay<_Tp>::type; #endif // is_abstract -namespace __is_abstract_imp -{ -template <class _Tp> char __test(_Tp (*)[1]); -template <class _Tp> __two __test(...); -} - -template <class _Tp, bool = is_class<_Tp>::value> -struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {}; - -template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}; - -template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract : public __libcpp_abstract<_Tp> {}; +template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract + : public integral_constant<bool, __is_abstract(_Tp)> {}; #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v @@ -1335,6 +1339,19 @@ template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v = is_final<_Tp>::value; #endif +// is_aggregate +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + +template <class _Tp> struct _LIBCPP_TEMPLATE_VIS +is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; + +#if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> +constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; +#endif + +#endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF @@ -1964,11 +1981,18 @@ public: typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp>::type type; }; +template <> +struct _LIBCPP_TEMPLATE_VIS common_type<void, void, void> +{ +public: + typedef void type; +}; + template <class _Tp> struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void> { public: - typedef typename decay<_Tp>::type type; + typedef typename common_type<_Tp, _Tp>::type type; }; template <class _Tp, class _Up> @@ -1990,9 +2014,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type {}; template <class _Tp> struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> -{ - typedef typename decay<_Tp>::type type; -}; + : public common_type<_Tp, _Tp> {}; // bullet 3 - sizeof...(Tp) == 2 @@ -4717,4 +4739,35 @@ struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy> _LIBCPP_END_NAMESPACE_STD +#if _LIBCPP_STD_VER > 14 +// std::byte +namespace std // purposefully not versioned +{ +template <class _Integer> + constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & + operator<<=(byte& __lhs, _Integer __shift) noexcept + { return __lhs = byte(static_cast<unsigned char>(__lhs) << __shift); } + +template <class _Integer> + constexpr typename enable_if<is_integral_v<_Integer>, byte>::type + operator<< (byte __lhs, _Integer __shift) noexcept + { return byte(static_cast<unsigned char>(__lhs) << __shift); } + +template <class _Integer> + constexpr typename enable_if<is_integral_v<_Integer>, byte>::type & + operator>>=(byte& __lhs, _Integer __shift) noexcept + { return __lhs = byte(static_cast<unsigned char>(__lhs) >> __shift); } + +template <class _Integer> + constexpr typename enable_if<is_integral_v<_Integer>, byte>::type + operator>> (byte __lhs, _Integer __shift) noexcept + { return byte(static_cast<unsigned char>(__lhs) >> __shift); } + +template <class _Integer> + constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type + to_integer(byte __b) noexcept { return _Integer(__b); } + +} +#endif + #endif // _LIBCPP_TYPE_TRAITS |