Redid nothrow traits in terms of non-nothrow traits when noexcept is available
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@131198 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3666695f0d
commit
5d37fb32d2
@ -86,8 +86,9 @@
|
|||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
|
||||||
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
//#if !__has_feature(cxx_alias_templates)
|
||||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||||
|
//#endif
|
||||||
|
|
||||||
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -138,6 +139,7 @@ typedef __char32_t char32_t;
|
|||||||
|
|
||||||
#if !(__has_feature(cxx_auto_type))
|
#if !(__has_feature(cxx_auto_type))
|
||||||
#define _LIBCPP_HAS_NO_AUTO_TYPE
|
#define _LIBCPP_HAS_NO_AUTO_TYPE
|
||||||
|
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(__has_feature(cxx_variadic_templates))
|
#if !(__has_feature(cxx_variadic_templates))
|
||||||
@ -162,6 +164,14 @@ namespace std {
|
|||||||
#define _LIBCPP_HAS_NO_CONSTEXPR
|
#define _LIBCPP_HAS_NO_CONSTEXPR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (__has_feature(cxx_noexcept))
|
||||||
|
# define _NOEXCEPT noexcept
|
||||||
|
# define _NOEXCEPT_(x) noexcept(x)
|
||||||
|
#else
|
||||||
|
# define _NOEXCEPT throw()
|
||||||
|
# define _NOEXCEPT_(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
// end defined(__clang__)
|
// end defined(__clang__)
|
||||||
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
@ -173,6 +183,9 @@ namespace std {
|
|||||||
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||||
#define _LIBCPP_HAS_NO_CONSTEXPR
|
#define _LIBCPP_HAS_NO_CONSTEXPR
|
||||||
|
|
||||||
|
#define _NOEXCEPT throw()
|
||||||
|
#define _NOEXCEPT_(x)
|
||||||
|
|
||||||
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
#ifndef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
|
||||||
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
|
||||||
|
@ -490,7 +490,7 @@ template <> struct _LIBCPP_VISIBLE add_rvalue_reference<const volatile
|
|||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
typename add_rvalue_reference<_Tp>::type
|
typename add_rvalue_reference<_Tp>::type
|
||||||
declval();
|
declval() _NOEXCEPT;
|
||||||
|
|
||||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
|
||||||
@ -2121,6 +2121,30 @@ template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_destructible
|
|||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||||
|
|
||||||
|
#if __has_feature(cxx_noexcept)
|
||||||
|
|
||||||
|
template <bool, class _Tp, class... _Args> struct __is_nothrow_constructible;
|
||||||
|
|
||||||
|
template <class _Tp, class... _Args>
|
||||||
|
struct __is_nothrow_constructible<true, _Tp, _Args...>
|
||||||
|
: public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Tp, class... _Args>
|
||||||
|
struct __is_nothrow_constructible<false, _Tp, _Args...>
|
||||||
|
: public false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Tp, class... _Args>
|
||||||
|
struct _LIBCPP_VISIBLE is_nothrow_constructible
|
||||||
|
: __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
#else // __has_feature(cxx_noexcept)
|
||||||
|
|
||||||
template <class _Tp, class... _Args>
|
template <class _Tp, class... _Args>
|
||||||
struct _LIBCPP_VISIBLE is_nothrow_constructible
|
struct _LIBCPP_VISIBLE is_nothrow_constructible
|
||||||
: false_type
|
: false_type
|
||||||
@ -2171,6 +2195,8 @@ struct _LIBCPP_VISIBLE is_nothrow_constructible<_Tp, _Tp&>
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // __has_feature(cxx_noexcept)
|
||||||
|
|
||||||
#else // _LIBCPP_HAS_NO_VARIADICS
|
#else // _LIBCPP_HAS_NO_VARIADICS
|
||||||
|
|
||||||
template <class _Tp, class _A0 = __is_construct::__nat,
|
template <class _Tp, class _A0 = __is_construct::__nat,
|
||||||
@ -2250,12 +2276,36 @@ template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_constructible
|
|||||||
|
|
||||||
// is_nothrow_assignable
|
// is_nothrow_assignable
|
||||||
|
|
||||||
|
#if __has_feature(cxx_noexcept)
|
||||||
|
|
||||||
|
template <bool, class _Tp, class _Arg> struct __is_nothrow_assignable;
|
||||||
|
|
||||||
template <class _Tp, class _Arg>
|
template <class _Tp, class _Arg>
|
||||||
struct is_nothrow_assignable
|
struct __is_nothrow_assignable<false, _Tp, _Arg>
|
||||||
|
: public false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Tp, class _Arg>
|
||||||
|
struct __is_nothrow_assignable<true, _Tp, _Arg>
|
||||||
|
: public integral_constant<bool, noexcept(_STD::declval<_Tp>() = _STD::declval<_Arg>()) >
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Tp, class _Arg>
|
||||||
|
struct _LIBCPP_VISIBLE is_nothrow_assignable
|
||||||
|
: public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
#else // __has_feature(cxx_noexcept)
|
||||||
|
|
||||||
|
template <class _Tp, class _Arg>
|
||||||
|
struct _LIBCPP_VISIBLE is_nothrow_assignable
|
||||||
: public false_type {};
|
: public false_type {};
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
struct is_nothrow_assignable<_Tp&, _Tp>
|
struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp>
|
||||||
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||||
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
|
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
|
||||||
#else
|
#else
|
||||||
@ -2263,7 +2313,7 @@ struct is_nothrow_assignable<_Tp&, _Tp>
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
struct is_nothrow_assignable<_Tp&, _Tp&>
|
struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, _Tp&>
|
||||||
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||||
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
|
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
|
||||||
#else
|
#else
|
||||||
@ -2271,7 +2321,7 @@ struct is_nothrow_assignable<_Tp&, _Tp&>
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
struct is_nothrow_assignable<_Tp&, const _Tp&>
|
struct _LIBCPP_VISIBLE is_nothrow_assignable<_Tp&, const _Tp&>
|
||||||
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
#if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||||
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
|
: integral_constant<bool, __has_nothrow_assign(_Tp)> {};
|
||||||
#else
|
#else
|
||||||
@ -2290,6 +2340,8 @@ struct is_nothrow_assignable<_Tp&, _Tp&&>
|
|||||||
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
#endif // __has_feature(cxx_noexcept)
|
||||||
|
|
||||||
// is_nothrow_copy_assignable
|
// is_nothrow_copy_assignable
|
||||||
|
|
||||||
template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable
|
template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_copy_assignable
|
||||||
@ -2310,6 +2362,30 @@ template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_move_assignable
|
|||||||
|
|
||||||
// is_nothrow_destructible
|
// is_nothrow_destructible
|
||||||
|
|
||||||
|
#if __has_feature(cxx_noexcept)
|
||||||
|
|
||||||
|
template <bool, class _Tp> struct __is_nothrow_destructible;
|
||||||
|
|
||||||
|
template <class _Tp>
|
||||||
|
struct __is_nothrow_destructible<false, _Tp>
|
||||||
|
: public false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Tp>
|
||||||
|
struct __is_nothrow_destructible<true, _Tp>
|
||||||
|
: public integral_constant<bool, noexcept(_STD::declval<_Tp>().~_Tp()) >
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Tp>
|
||||||
|
struct _LIBCPP_VISIBLE is_nothrow_destructible
|
||||||
|
: public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
template <class _Tp> struct __libcpp_nothrow_destructor
|
template <class _Tp> struct __libcpp_nothrow_destructor
|
||||||
: public integral_constant<bool, is_scalar<_Tp>::value ||
|
: public integral_constant<bool, is_scalar<_Tp>::value ||
|
||||||
is_reference<_Tp>::value> {};
|
is_reference<_Tp>::value> {};
|
||||||
@ -2317,6 +2393,8 @@ template <class _Tp> struct __libcpp_nothrow_destructor
|
|||||||
template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible
|
template <class _Tp> struct _LIBCPP_VISIBLE is_nothrow_destructible
|
||||||
: public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
|
: public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// is_pod
|
// is_pod
|
||||||
|
|
||||||
#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
#if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user