diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2010-09-06 19:10:31 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2010-09-06 19:10:31 +0000 |
| commit | db3e9975d0f959cb0d73f17940a716e5593c985b (patch) | |
| tree | 3e4addd7785e97b2290bd1ff00b6cf7f9c04e324 /libcxx/include | |
| parent | d05f3e37306267ccf59843ab71367c180d2179c0 (diff) | |
| download | bcm5719-llvm-db3e9975d0f959cb0d73f17940a716e5593c985b.tar.gz bcm5719-llvm-db3e9975d0f959cb0d73f17940a716e5593c985b.zip | |
Working the type_traits area: Hooked up to clang's __is_union. Got has_trivial_copy_assign working.
llvm-svn: 113162
Diffstat (limited to 'libcxx/include')
| -rw-r--r-- | libcxx/include/__config | 9 | ||||
| -rw-r--r-- | libcxx/include/type_traits | 31 |
2 files changed, 34 insertions, 6 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config index a5a2d1f0ef7..87213fcbdfe 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -152,6 +152,10 @@ using namespace _LIBCPP_NAMESPACE; #define _STD std #endif // __has_feature(cxx_inline_namespaces) +#if !(__has_feature(cxx_constexpr)) +#define _LIBCPP_HAS_NO_CONSTEXPR +#endif + // end defined(__clang__) #elif defined(__GNUC__) @@ -161,6 +165,7 @@ using namespace _LIBCPP_NAMESPACE; #endif #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#define _LIBCPP_HAS_NO_CONSTEXPR #ifndef __GXX_EXPERIMENTAL_CXX0X__ @@ -231,4 +236,8 @@ template <unsigned> struct __static_assert_check {}; #define decltype(x) __typeof__(x) #endif +#ifdef _LIBCPP_HAS_NO_CONSTEXPR +#define constexpr const +#endif + #endif // _LIBCPP_CONFIG diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 5cdcf12f237..5624c4ec18f 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -34,7 +34,6 @@ namespace std template <class T> struct is_pointer; template <class T> struct is_lvalue_reference; template <class T> struct is_rvalue_reference; - template <class T> struct is_reference; template <class T> struct is_member_object_pointer; template <class T> struct is_member_function_pointer; template <class T> struct is_enum; @@ -152,9 +151,12 @@ struct __two {char _[2];}; template <class _Tp, _Tp __v> struct integral_constant { - static const _Tp value = __v; + static constexpr _Tp value = __v; typedef _Tp value_type; typedef integral_constant type; +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + constexpr operator value_type() {return value;} +#endif }; template <class _Tp, _Tp __v> @@ -258,7 +260,7 @@ template <class _Tp> struct is_reference<_Tp&&> : public true_type {}; // is_union -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 +#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 || defined(__clang__) template <class _Tp> struct is_union : public integral_constant<bool, __is_union(_Tp)> {}; @@ -725,13 +727,30 @@ template <class _Tp> struct has_nothrow_move_constructor : public has_nothrow_co template <class _Tp> struct has_copy_constructor : public true_type {}; +// has_copy_assign + +template <class _Tp> struct has_copy_assign; + // has_trivial_copy_assign -template <class _Tp> struct __libcpp_trivial_copy_assign : public integral_constant<bool, !is_const<_Tp>::value && - is_scalar<_Tp>::value> {}; +#if defined(__clang__) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) + +template <class _Tp, bool = is_void<_Tp>::value> +struct __has_trivial_copy_assign + : public integral_constant<bool, __has_trivial_assign(_Tp)> {}; + +template <class _Tp> struct __has_trivial_copy_assign<_Tp, true> + : public false_type {}; template <class _Tp> struct has_trivial_copy_assign - : public __libcpp_trivial_copy_assign<typename remove_all_extents<_Tp>::type> {}; + : __has_trivial_copy_assign<_Tp> {}; + +#else + +template <class _Tp> struct has_trivial_copy_assign + : public integral_constant<bool, is_scalar<_Tp>::value && !is_const<_Tp>::value> {}; + +#endif // defined(__clang__) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) // has_nothrow_copy_assign |

