[libc++] Remove various C++03 feature test macros

Summary:
Libc++ still uses per-feature configuration macros when configuring for C++11. However libc++ requires a feature-complete C++11 compiler so there is no reason to check individual features. This patch starts the process of removing the feature specific macros and replacing their usage with `_LIBCPP_CXX03_LANG`.

This patch removes the __config macros:

* _LIBCPP_HAS_NO_TRAILING_RETURN
* _LIBCPP_HAS_NO_TEMPLATE_ALIASES
* _LIBCPP_HAS_NO_ADVANCED_SFINAE
* _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
* _LIBCPP_HAS_NO_STATIC_ASSERT

As a drive I also changed our C++03 static_assert to use _Static_assert if available.

I plan to commit this without review if nobody voices an objection.

Reviewers: mclow.lists

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D24895

llvm-svn: 282347
This commit is contained in:
Eric Fiselier 2016-09-25 03:34:28 +00:00
parent 84505f9a9c
commit 54613ab4d4
25 changed files with 114 additions and 150 deletions

View File

@ -68,6 +68,9 @@
#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
#if __cplusplus < 201103L
#define _LIBCPP_CXX03_LANG
#endif
#ifndef __has_attribute #ifndef __has_attribute
#define __has_attribute(__x) 0 #define __has_attribute(__x) 0
@ -229,10 +232,6 @@
# define _ALIGNAS(x) __attribute__((__aligned__(x))) # define _ALIGNAS(x) __attribute__((__aligned__(x)))
#endif #endif
#if !__has_feature(cxx_alias_templates)
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif
#if __cplusplus < 201103L #if __cplusplus < 201103L
typedef __char16_t char16_t; typedef __char16_t char16_t;
typedef __char32_t char32_t; typedef __char32_t char32_t;
@ -260,10 +259,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_NORETURN __attribute__ ((noreturn)) # define _LIBCPP_NORETURN __attribute__ ((noreturn))
#endif #endif
#if !(__has_feature(cxx_default_function_template_args))
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#endif
#if !(__has_feature(cxx_defaulted_functions)) #if !(__has_feature(cxx_defaulted_functions))
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif // !(__has_feature(cxx_defaulted_functions)) #endif // !(__has_feature(cxx_defaulted_functions))
@ -284,26 +279,14 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif #endif
#if !(__has_feature(cxx_static_assert))
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#endif
#if !(__has_feature(cxx_auto_type)) #if !(__has_feature(cxx_auto_type))
#define _LIBCPP_HAS_NO_AUTO_TYPE #define _LIBCPP_HAS_NO_AUTO_TYPE
#endif #endif
#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#endif
#if !(__has_feature(cxx_variadic_templates)) #if !(__has_feature(cxx_variadic_templates))
#define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_VARIADICS
#endif #endif
#if !(__has_feature(cxx_trailing_return))
#define _LIBCPP_HAS_NO_TRAILING_RETURN
#endif
#if !(__has_feature(cxx_generalized_initializers)) #if !(__has_feature(cxx_generalized_initializers))
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif #endif
@ -428,34 +411,26 @@ namespace std {
#endif #endif
#ifndef __GXX_EXPERIMENTAL_CXX0X__ #ifndef __GXX_EXPERIMENTAL_CXX0X__
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DECLTYPE
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#define _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_HAS_NO_STRONG_ENUMS
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NOEXCEPT
#else // __GXX_EXPERIMENTAL_CXX0X__ #else // __GXX_EXPERIMENTAL_CXX0X__
#if _GNUC_VER < 403 #if _GNUC_VER < 403
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#endif #endif
#if _GNUC_VER < 404 #if _GNUC_VER < 404
#define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DECLTYPE
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_TRAILING_RETURN
#define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@ -464,11 +439,9 @@ namespace std {
#if _GNUC_VER < 406 #if _GNUC_VER < 406
#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NOEXCEPT
#define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif #endif
#if _GNUC_VER < 407 #if _GNUC_VER < 407
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif #endif
@ -490,7 +463,6 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
#elif defined(_LIBCPP_MSVC) #elif defined(_LIBCPP_MSVC)
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_CONSTEXPR
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
@ -520,9 +492,6 @@ namespace std {
#define _ATTRIBUTE(x) __attribute__((x)) #define _ATTRIBUTE(x) __attribute__((x))
#define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_NORETURN __attribute__((noreturn))
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NOEXCEPT
#define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_NULLPTR
@ -677,8 +646,10 @@ typedef unsigned int char32_t;
#define _LIBCPP_HAS_NO_INT128 #define _LIBCPP_HAS_NO_INT128
#endif #endif
#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT #ifdef _LIBCPP_CXX03_LANG
# if __has_extension(c_static_assert)
# define static_assert(__b, __m) _Static_assert(__b, __m)
# else
extern "C++" { extern "C++" {
template <bool> struct __static_assert_test; template <bool> struct __static_assert_test;
template <> struct __static_assert_test<true> {}; template <> struct __static_assert_test<true> {};
@ -687,8 +658,8 @@ template <unsigned> struct __static_assert_check {};
#define static_assert(__b, __m) \ #define static_assert(__b, __m) \
typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \ typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
_LIBCPP_CONCAT(__t, __LINE__) _LIBCPP_CONCAT(__t, __LINE__)
# endif // __has_extension(c_static_assert)
#endif // _LIBCPP_HAS_NO_STATIC_ASSERT #endif // _LIBCPP_CXX03_LANG
#ifdef _LIBCPP_HAS_NO_DECLTYPE #ifdef _LIBCPP_HAS_NO_DECLTYPE
// GCC 4.6 provides __decltype in all standard modes. // GCC 4.6 provides __decltype in all standard modes.
@ -934,14 +905,6 @@ extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
#endif #endif
#if __cplusplus < 201103L
#define _LIBCPP_CXX03_LANG
#else
#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
#endif
#endif
#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \ #if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
&& __has_attribute(acquire_capability)) && __has_attribute(acquire_capability))
#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS #define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS

View File

@ -1566,7 +1566,7 @@ end(_Tp (&__array)[_Np])
return __array + _Np; return __array + _Np;
} }
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) #if !defined(_LIBCPP_CXX03_LANG)
template <class _Cp> template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
@ -1689,7 +1689,7 @@ auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
#endif #endif
#else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) #else // defined(_LIBCPP_CXX03_LANG)
template <class _Cp> template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
@ -1723,7 +1723,7 @@ end(const _Cp& __c)
return __c.end(); return __c.end();
} }
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) #endif // !defined(_LIBCPP_CXX03_LANG)
#if _LIBCPP_STD_VER > 14 #if _LIBCPP_STD_VER > 14
template <class _Cont> template <class _Cont>

View File

@ -828,7 +828,7 @@ public:
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
struct __pointer_traits_rebind struct __pointer_traits_rebind
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename _Tp::template rebind<_Up> type; typedef typename _Tp::template rebind<_Up> type;
#else #else
typedef typename _Tp::template rebind<_Up>::other type; typedef typename _Tp::template rebind<_Up>::other type;
@ -840,7 +840,7 @@ struct __pointer_traits_rebind
template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
#else #else
typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
@ -858,7 +858,7 @@ struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
template <template <class> class _Sp, class _Tp, class _Up> template <template <class> class _Sp, class _Tp, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true>
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp>::template rebind<_Up> type; typedef typename _Sp<_Tp>::template rebind<_Up> type;
#else #else
typedef typename _Sp<_Tp>::template rebind<_Up>::other type; typedef typename _Sp<_Tp>::template rebind<_Up>::other type;
@ -874,7 +874,7 @@ struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false>
template <template <class, class> class _Sp, class _Tp, class _A0, class _Up> template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true>
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type;
#else #else
typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type;
@ -891,7 +891,7 @@ template <template <class, class, class> class _Sp, class _Tp, class _A0,
class _A1, class _Up> class _A1, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true>
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type;
#else #else
typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type;
@ -909,7 +909,7 @@ template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
class _A1, class _A2, class _Up> class _A1, class _A2, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true>
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type;
#else #else
typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type;
@ -932,12 +932,12 @@ struct _LIBCPP_TYPE_VIS_ONLY pointer_traits
typedef typename __pointer_traits_element_type<pointer>::type element_type; typedef typename __pointer_traits_element_type<pointer>::type element_type;
typedef typename __pointer_traits_difference_type<pointer>::type difference_type; typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
#else #else
template <class _Up> struct rebind template <class _Up> struct rebind
{typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif // _LIBCPP_CXX03_LANG
private: private:
struct __nat {}; struct __nat {};
@ -955,7 +955,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*>
typedef _Tp element_type; typedef _Tp element_type;
typedef ptrdiff_t difference_type; typedef ptrdiff_t difference_type;
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
template <class _Up> using rebind = _Up*; template <class _Up> using rebind = _Up*;
#else #else
template <class _Up> struct rebind {typedef _Up* other;}; template <class _Up> struct rebind {typedef _Up* other;};
@ -972,7 +972,7 @@ public:
template <class _From, class _To> template <class _From, class _To>
struct __rebind_pointer { struct __rebind_pointer {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename pointer_traits<_From>::template rebind<_To> type; typedef typename pointer_traits<_From>::template rebind<_To> type;
#else #else
typedef typename pointer_traits<_From>::template rebind<_To>::other type; typedef typename pointer_traits<_From>::template rebind<_To>::other type;
@ -1036,7 +1036,7 @@ struct __const_pointer
template <class _Tp, class _Ptr, class _Alloc> template <class _Tp, class _Ptr, class _Alloc>
struct __const_pointer<_Tp, _Ptr, _Alloc, false> struct __const_pointer<_Tp, _Ptr, _Alloc, false>
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
#else #else
typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type;
@ -1063,7 +1063,7 @@ struct __void_pointer
template <class _Ptr, class _Alloc> template <class _Ptr, class _Alloc>
struct __void_pointer<_Ptr, _Alloc, false> struct __void_pointer<_Ptr, _Alloc, false>
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename pointer_traits<_Ptr>::template rebind<void> type; typedef typename pointer_traits<_Ptr>::template rebind<void> type;
#else #else
typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; typedef typename pointer_traits<_Ptr>::template rebind<void>::other type;
@ -1090,7 +1090,7 @@ struct __const_void_pointer
template <class _Ptr, class _Alloc> template <class _Ptr, class _Alloc>
struct __const_void_pointer<_Ptr, _Alloc, false> struct __const_void_pointer<_Ptr, _Alloc, false>
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename pointer_traits<_Ptr>::template rebind<const void> type; typedef typename pointer_traits<_Ptr>::template rebind<const void> type;
#else #else
typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type;
@ -1321,7 +1321,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false>
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_VARIADICS
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #ifndef _LIBCPP_CXX03_LANG
template <class _Alloc, class _SizeType, class _ConstVoidPtr> template <class _Alloc, class _SizeType, class _ConstVoidPtr>
auto auto
@ -1344,7 +1344,7 @@ struct __has_allocate_hint
{ {
}; };
#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE #else // _LIBCPP_CXX03_LANG
template <class _Alloc, class _SizeType, class _ConstVoidPtr> template <class _Alloc, class _SizeType, class _ConstVoidPtr>
struct __has_allocate_hint struct __has_allocate_hint
@ -1352,9 +1352,9 @@ struct __has_allocate_hint
{ {
}; };
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif // _LIBCPP_CXX03_LANG
#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS) #if !defined(_LIBCPP_CXX03_LANG)
template <class _Alloc, class _Tp, class ..._Args> template <class _Alloc, class _Tp, class ..._Args>
decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(),
@ -1435,7 +1435,7 @@ struct __has_select_on_container_copy_construction
{ {
}; };
#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE #else // _LIBCPP_CXX03_LANG
#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS
@ -1473,7 +1473,7 @@ struct __has_select_on_container_copy_construction
{ {
}; };
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif // _LIBCPP_CXX03_LANG
template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
struct __alloc_traits_difference_type struct __alloc_traits_difference_type
@ -1510,16 +1510,16 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
typedef typename __is_always_equal<allocator_type>::type typedef typename __is_always_equal<allocator_type>::type
is_always_equal; is_always_equal;
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
template <class _Tp> using rebind_alloc = template <class _Tp> using rebind_alloc =
typename __allocator_traits_rebind<allocator_type, _Tp>::type; typename __allocator_traits_rebind<allocator_type, _Tp>::type;
template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #else // _LIBCPP_CXX03_LANG
template <class _Tp> struct rebind_alloc template <class _Tp> struct rebind_alloc
{typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;}; {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;};
template <class _Tp> struct rebind_traits template <class _Tp> struct rebind_traits
{typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;}; {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
static pointer allocate(allocator_type& __a, size_type __n) static pointer allocate(allocator_type& __a, size_type __n)
@ -1731,7 +1731,7 @@ private:
template <class _Traits, class _Tp> template <class _Traits, class _Tp>
struct __rebind_alloc_helper struct __rebind_alloc_helper
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
typedef typename _Traits::template rebind_alloc<_Tp> type; typedef typename _Traits::template rebind_alloc<_Tp> type;
#else #else
typedef typename _Traits::template rebind_alloc<_Tp>::other type; typedef typename _Traits::template rebind_alloc<_Tp>::other type;

View File

@ -300,18 +300,18 @@ public:
>::type type; >::type type;
}; };
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
template <class _R1, class _R2> using ratio_multiply template <class _R1, class _R2> using ratio_multiply
= typename __ratio_multiply<_R1, _R2>::type; = typename __ratio_multiply<_R1, _R2>::type;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #else // _LIBCPP_CXX03_LANG
template <class _R1, class _R2> template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_multiply struct _LIBCPP_TYPE_VIS_ONLY ratio_multiply
: public __ratio_multiply<_R1, _R2>::type {}; : public __ratio_multiply<_R1, _R2>::type {};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2> template <class _R1, class _R2>
struct __ratio_divide struct __ratio_divide
@ -327,18 +327,18 @@ public:
>::type type; >::type type;
}; };
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
template <class _R1, class _R2> using ratio_divide template <class _R1, class _R2> using ratio_divide
= typename __ratio_divide<_R1, _R2>::type; = typename __ratio_divide<_R1, _R2>::type;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #else // _LIBCPP_CXX03_LANG
template <class _R1, class _R2> template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_divide struct _LIBCPP_TYPE_VIS_ONLY ratio_divide
: public __ratio_divide<_R1, _R2>::type {}; : public __ratio_divide<_R1, _R2>::type {};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2> template <class _R1, class _R2>
struct __ratio_add struct __ratio_add
@ -362,18 +362,18 @@ public:
>::type type; >::type type;
}; };
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
template <class _R1, class _R2> using ratio_add template <class _R1, class _R2> using ratio_add
= typename __ratio_add<_R1, _R2>::type; = typename __ratio_add<_R1, _R2>::type;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #else // _LIBCPP_CXX03_LANG
template <class _R1, class _R2> template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_add struct _LIBCPP_TYPE_VIS_ONLY ratio_add
: public __ratio_add<_R1, _R2>::type {}; : public __ratio_add<_R1, _R2>::type {};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2> template <class _R1, class _R2>
struct __ratio_subtract struct __ratio_subtract
@ -397,18 +397,18 @@ public:
>::type type; >::type type;
}; };
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #ifndef _LIBCPP_CXX03_LANG
template <class _R1, class _R2> using ratio_subtract template <class _R1, class _R2> using ratio_subtract
= typename __ratio_subtract<_R1, _R2>::type; = typename __ratio_subtract<_R1, _R2>::type;
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #else // _LIBCPP_CXX03_LANG
template <class _R1, class _R2> template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract
: public __ratio_subtract<_R1, _R2>::type {}; : public __ratio_subtract<_R1, _R2>::type {};
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif // _LIBCPP_CXX03_LANG
// ratio_equal // ratio_equal

View File

@ -115,7 +115,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) #if !defined(_LIBCPP_CXX03_LANG)
// scoped_allocator_adaptor // scoped_allocator_adaptor
@ -597,7 +597,7 @@ operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
return !(__a == __b); return !(__a == __b);
} }
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) #endif // !defined(_LIBCPP_CXX03_LANG)
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

View File

@ -4351,7 +4351,7 @@ template <class _Tp> struct __is_nothrow_swappable;
template <class _Tp> template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #ifndef _LIBCPP_CXX03_LANG
typename enable_if typename enable_if
< <
is_move_constructible<_Tp>::value && is_move_constructible<_Tp>::value &&
@ -4559,7 +4559,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename __sfinae_underlying_type<_Tp>::__promoted_type typename __sfinae_underlying_type<_Tp>::__promoted_type
__convert_to_integral(_Tp __val) { return __val; } __convert_to_integral(_Tp __val) { return __val; }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #ifndef _LIBCPP_CXX03_LANG
template <class _Tp> template <class _Tp>
struct __has_operator_addressof_member_imp struct __has_operator_addressof_member_imp
@ -4591,7 +4591,7 @@ struct __has_operator_addressof
|| __has_operator_addressof_free_imp<_Tp>::value> || __has_operator_addressof_free_imp<_Tp>::value>
{}; {};
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 14 #if _LIBCPP_STD_VER > 14
template <class...> using void_t = void; template <class...> using void_t = void;

View File

@ -16,6 +16,7 @@
#include <map> #include <map>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "test_allocator.h" #include "test_allocator.h"
#include "min_allocator.h" #include "min_allocator.h"
@ -56,7 +57,7 @@ int main()
assert(*next(mo.begin()) == V(2, 1)); assert(*next(mo.begin()) == V(2, 1));
assert(*next(mo.begin(), 2) == V(3, 1)); assert(*next(mo.begin(), 2) == V(3, 1));
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef std::pair<const int, double> V; typedef std::pair<const int, double> V;
V ar[] = V ar[] =
@ -91,8 +92,6 @@ int main()
assert(*next(mo.begin()) == V(2, 1)); assert(*next(mo.begin()) == V(2, 1));
assert(*next(mo.begin(), 2) == V(3, 1)); assert(*next(mo.begin(), 2) == V(3, 1));
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
typedef std::pair<const int, double> V; typedef std::pair<const int, double> V;
V ar[] = V ar[] =

View File

@ -16,6 +16,7 @@
#include <map> #include <map>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "test_allocator.h" #include "test_allocator.h"
#include "min_allocator.h" #include "min_allocator.h"
@ -47,7 +48,7 @@ int main()
assert(mo.get_allocator() == A(7)); assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5)); assert(mo.key_comp() == C(5));
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef std::pair<const int, double> V; typedef std::pair<const int, double> V;
V ar[] = V ar[] =
@ -73,8 +74,6 @@ int main()
assert(mo.get_allocator() == A(7)); assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5)); assert(mo.key_comp() == C(5));
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
typedef std::pair<const int, double> V; typedef std::pair<const int, double> V;
V ar[] = V ar[] =

View File

@ -16,6 +16,7 @@
#include <set> #include <set>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "test_allocator.h" #include "test_allocator.h"
@ -67,7 +68,7 @@ int main()
assert(*next(mo.begin(), 7) == 3); assert(*next(mo.begin(), 7) == 3);
assert(*next(mo.begin(), 8) == 3); assert(*next(mo.begin(), 8) == 3);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef int V; typedef int V;
V ar[] = V ar[] =
@ -114,5 +115,5 @@ int main()
assert(*next(mo.begin(), 7) == 3); assert(*next(mo.begin(), 7) == 3);
assert(*next(mo.begin(), 8) == 3); assert(*next(mo.begin(), 8) == 3);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif
} }

View File

@ -16,6 +16,7 @@
#include <set> #include <set>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "test_allocator.h" #include "test_allocator.h"
@ -55,7 +56,7 @@ int main()
assert(*next(mo.begin()) == 2); assert(*next(mo.begin()) == 2);
assert(*next(mo.begin(), 2) == 3); assert(*next(mo.begin(), 2) == 3);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef int V; typedef int V;
V ar[] = V ar[] =
@ -90,5 +91,5 @@ int main()
assert(*next(mo.begin()) == 2); assert(*next(mo.begin()) == 2);
assert(*next(mo.begin(), 2) == 3); assert(*next(mo.begin(), 2) == 3);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif
} }

View File

@ -13,6 +13,8 @@
#include <deque> #include <deque>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "test_allocator.h" #include "test_allocator.h"
#include "min_allocator.h" #include "min_allocator.h"
@ -37,15 +39,13 @@ int main()
assert(v2 == v); assert(v2 == v);
assert(v2.get_allocator() == v.get_allocator()); assert(v2.get_allocator() == v.get_allocator());
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5)); std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
std::deque<int, other_allocator<int> > v2 = v; std::deque<int, other_allocator<int> > v2 = v;
assert(v2 == v); assert(v2 == v);
assert(v2.get_allocator() == other_allocator<int>(-2)); assert(v2.get_allocator() == other_allocator<int>(-2));
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]); int* an = ab + sizeof(ab)/sizeof(ab[0]);

View File

@ -15,6 +15,7 @@
#include <cassert> #include <cassert>
#include <iterator> #include <iterator>
#include "test_macros.h"
#include "test_allocator.h" #include "test_allocator.h"
#include "min_allocator.h" #include "min_allocator.h"
@ -34,7 +35,7 @@ int main()
assert(c == c0); assert(c == c0);
assert(c.get_allocator() == A(10)); assert(c.get_allocator() == A(10));
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef int T; typedef int T;
typedef other_allocator<int> A; typedef other_allocator<int> A;
@ -49,8 +50,6 @@ int main()
assert(c == c0); assert(c == c0);
assert(c.get_allocator() == A(-2)); assert(c.get_allocator() == A(-2));
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
typedef int T; typedef int T;
typedef min_allocator<int> A; typedef min_allocator<int> A;

View File

@ -13,6 +13,8 @@
#include <list> #include <list>
#include <cassert> #include <cassert>
#include "test_macros.h"
#include "DefaultOnly.h" #include "DefaultOnly.h"
#include "test_allocator.h" #include "test_allocator.h"
#include "min_allocator.h" #include "min_allocator.h"
@ -30,15 +32,13 @@ int main()
assert(l2 == l); assert(l2 == l);
assert(l2.get_allocator() == l.get_allocator()); assert(l2.get_allocator() == l.get_allocator());
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5)); std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
std::list<int, other_allocator<int> > l2 = l; std::list<int, other_allocator<int> > l2 = l;
assert(l2 == l); assert(l2 == l);
assert(l2.get_allocator() == other_allocator<int>(-2)); assert(l2.get_allocator() == other_allocator<int>(-2));
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
std::list<int, min_allocator<int>> l(3, 2); std::list<int, min_allocator<int>> l(3, 2);
std::list<int, min_allocator<int>> l2 = l; std::list<int, min_allocator<int>> l2 = l;

View File

@ -68,7 +68,7 @@ int main()
assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef std::unordered_map<int, std::string, typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >, test_hash<std::hash<int> >,
@ -108,8 +108,6 @@ int main()
assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
typedef std::unordered_map<int, std::string, typedef std::unordered_map<int, std::string,
test_hash<std::hash<int> >, test_hash<std::hash<int> >,

View File

@ -82,7 +82,7 @@ int main()
assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef std::unordered_multimap<int, std::string, typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >, test_hash<std::hash<int> >,
@ -136,8 +136,6 @@ int main()
assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
typedef std::unordered_multimap<int, std::string, typedef std::unordered_multimap<int, std::string,
test_hash<std::hash<int> >, test_hash<std::hash<int> >,

View File

@ -74,7 +74,7 @@ int main()
assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef std::unordered_multiset<int, typedef std::unordered_multiset<int,
test_hash<std::hash<int> >, test_hash<std::hash<int> >,
@ -121,8 +121,6 @@ int main()
assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
typedef std::unordered_multiset<int, typedef std::unordered_multiset<int,
test_hash<std::hash<int> >, test_hash<std::hash<int> >,

View File

@ -66,7 +66,7 @@ int main()
assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
typedef std::unordered_set<int, typedef std::unordered_set<int,
test_hash<std::hash<int> >, test_hash<std::hash<int> >,
@ -105,8 +105,6 @@ int main()
assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
#if TEST_STD_VER >= 11
{ {
typedef std::unordered_set<int, typedef std::unordered_set<int,
test_hash<std::hash<int> >, test_hash<std::hash<int> >,

View File

@ -20,6 +20,8 @@
#include <cstdint> #include <cstdint>
#include <cassert> #include <cassert>
#include "test_macros.h"
template <class T> template <class T>
struct A struct A
{ {
@ -52,10 +54,10 @@ struct B
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
A<int> a; A<int> a;
assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xDEADBEEF))); assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xDEADBEEF)));
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif
B<int> b; B<int> b;
assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xFEADBEEF))); assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xFEADBEEF)));
} }

View File

@ -22,6 +22,8 @@
#include <type_traits> #include <type_traits>
#include <cassert> #include <cassert>
#include "test_macros.h"
template <class T> template <class T>
struct A struct A
{ {
@ -36,14 +38,14 @@ struct B
{ {
typedef T value_type; typedef T value_type;
#ifndef _LIBCPP_HAS_NO_VARIADICS #if TEST_STD_VER >= 11
template <class U, class ...Args> template <class U, class ...Args>
void construct(U* p, Args&& ...args) void construct(U* p, Args&& ...args)
{ {
++b_construct; ++b_construct;
::new ((void*)p) U(std::forward<Args>(args)...); ::new ((void*)p) U(std::forward<Args>(args)...);
} }
#endif // _LIBCPP_HAS_NO_VARIADICS #endif
}; };
struct A0 struct A0
@ -105,7 +107,7 @@ int main()
std::allocator_traits<A<int> >::construct(a, (A2*)&a2, 'd', 5); std::allocator_traits<A<int> >::construct(a, (A2*)&a2, 'd', 5);
assert(A2::count == 1); assert(A2::count == 1);
} }
#ifndef _LIBCPP_HAS_NO_VARIADICS #if TEST_STD_VER >= 11
{ {
A0::count = 0; A0::count = 0;
b_construct = 0; b_construct = 0;
@ -139,5 +141,5 @@ int main()
assert(A2::count == 1); assert(A2::count == 1);
assert(b_construct == 1); assert(b_construct == 1);
} }
#endif // _LIBCPP_HAS_NO_VARIADICS #endif
} }

View File

@ -22,6 +22,8 @@
#include <type_traits> #include <type_traits>
#include <cassert> #include <cassert>
#include "test_macros.h"
template <class T> template <class T>
struct A struct A
{ {
@ -63,7 +65,7 @@ int main()
std::allocator_traits<A<int> >::destroy(a, (A0*)&a0); std::allocator_traits<A<int> >::destroy(a, (A0*)&a0);
assert(A0::count == 1); assert(A0::count == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
A0::count = 0; A0::count = 0;
b_destroy = 0; b_destroy = 0;
@ -76,5 +78,5 @@ int main()
assert(A0::count == 1); assert(A0::count == 1);
assert(b_destroy == 1); assert(b_destroy == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif
} }

View File

@ -43,18 +43,6 @@ struct B
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
{
A<int> a;
assert(std::allocator_traits<A<int> >::max_size(a) ==
std::numeric_limits<std::size_t>::max() / sizeof(int));
}
{
const A<int> a = {};
assert(std::allocator_traits<A<int> >::max_size(a) ==
std::numeric_limits<std::size_t>::max() / sizeof(int));
}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
{ {
B<int> b; B<int> b;
assert(std::allocator_traits<B<int> >::max_size(b) == 100); assert(std::allocator_traits<B<int> >::max_size(b) == 100);
@ -64,6 +52,16 @@ int main()
assert(std::allocator_traits<B<int> >::max_size(b) == 100); assert(std::allocator_traits<B<int> >::max_size(b) == 100);
} }
#if TEST_STD_VER >= 11 #if TEST_STD_VER >= 11
{
A<int> a;
assert(std::allocator_traits<A<int> >::max_size(a) ==
std::numeric_limits<std::size_t>::max() / sizeof(int));
}
{
const A<int> a = {};
assert(std::allocator_traits<A<int> >::max_size(a) ==
std::numeric_limits<std::size_t>::max() / sizeof(int));
}
{ {
std::allocator<int> a; std::allocator<int> a;
static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, ""); static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, "");

View File

@ -22,6 +22,8 @@
#include <type_traits> #include <type_traits>
#include <cassert> #include <cassert>
#include "test_macros.h"
template <class T> template <class T>
struct A struct A
{ {
@ -55,7 +57,7 @@ int main()
const A<int> a(0); const A<int> a(0);
assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0); assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER >= 11
{ {
B<int> b; B<int> b;
assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100); assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
@ -64,5 +66,5 @@ int main()
const B<int> b(0); const B<int> b(0);
assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100); assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif
} }

View File

@ -19,6 +19,8 @@
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
#include "test_macros.h"
template <class T> template <class T>
struct ReboundA {}; struct ReboundA {};
@ -63,17 +65,17 @@ struct E
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #if TEST_STD_VER >= 11
static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<ReboundA<double> > >::value), ""); static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<ReboundA<double> > >::value), "");
static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<ReboundB<double, char> > >::value), ""); static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<ReboundB<double, char> > >::value), "");
static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), ""); static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), "");
static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), ""); static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), "");
static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), ""); static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), "");
#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #else
static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<ReboundA<double> > >::value), ""); static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<ReboundA<double> > >::value), "");
static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<ReboundB<double, char> > >::value), ""); static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<ReboundB<double, char> > >::value), "");
static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), ""); static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), "");
static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), ""); static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), "");
static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), ""); static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), "");
#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES #endif
} }

View File

@ -19,9 +19,11 @@
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
#include "test_macros.h"
int main() int main()
{ {
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES #if TEST_STD_VER >= 11
static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), ""); static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), "");
#else #else
static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), ""); static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), "");

View File

@ -66,7 +66,7 @@ public:
{ {
assert(data_ >= 0); assert(data_ >= 0);
if (time_to_throw >= throw_after) { if (time_to_throw >= throw_after) {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef TEST_HAS_NO_EXCEPTIONS
throw std::bad_alloc(); throw std::bad_alloc();
#else #else
std::terminate(); std::terminate();
@ -130,7 +130,7 @@ public:
{ {
assert(data_ >= 0); assert(data_ >= 0);
if (time_to_throw >= throw_after) { if (time_to_throw >= throw_after) {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef TEST_HAS_NO_EXCEPTIONS
throw std::bad_alloc(); throw std::bad_alloc();
#else #else
std::terminate(); std::terminate();
@ -221,10 +221,10 @@ public:
typedef std::true_type propagate_on_container_move_assignment; typedef std::true_type propagate_on_container_move_assignment;
typedef std::true_type propagate_on_container_swap; typedef std::true_type propagate_on_container_swap;
#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE #if TEST_STD_VER < 11
std::size_t max_size() const std::size_t max_size() const
{return UINT_MAX / sizeof(T);} {return UINT_MAX / sizeof(T);}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif
}; };