[libc++][P0174] Deprecated/removed parts of default allocator.
Differential Revision: https://reviews.llvm.org/D70117
This commit is contained in:
committed by
Louis Dionne
parent
0ab109d43d
commit
5b1e5b4338
@@ -80,7 +80,7 @@ struct allocator_traits
|
||||
typedef Alloc::is_always_equal
|
||||
| is_empty is_always_equal;
|
||||
|
||||
template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>;
|
||||
template <class T> using rebind_alloc = Alloc::rebind<T>::other | Alloc<T, Args...>;
|
||||
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
|
||||
|
||||
static pointer allocate(allocator_type& a, size_type n); // [[nodiscard]] in C++20
|
||||
@@ -101,7 +101,7 @@ struct allocator_traits
|
||||
};
|
||||
|
||||
template <>
|
||||
class allocator<void>
|
||||
class allocator<void> // deprecated in C++17, removed in C++20
|
||||
{
|
||||
public:
|
||||
typedef void* pointer;
|
||||
@@ -115,30 +115,37 @@ template <class T>
|
||||
class allocator
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef typename add_lvalue_reference<T>::type reference;
|
||||
typedef typename add_lvalue_reference<const T>::type const_reference;
|
||||
typedef T value_type;
|
||||
typedef size_t size_type; // deprecated in C++17, removed in C++20
|
||||
typedef ptrdiff_t difference_type; // deprecated in C++17, removed in C++20
|
||||
typedef T* pointer; // deprecated in C++17, removed in C++20
|
||||
typedef const T* const_pointer; // deprecated in C++17, removed in C++20
|
||||
typedef typename add_lvalue_reference<T>::type
|
||||
reference; // deprecated in C++17, removed in C++20
|
||||
typedef typename add_lvalue_reference<const T>::type
|
||||
const_reference; // deprecated in C++17, removed in C++20
|
||||
|
||||
template <class U> struct rebind {typedef allocator<U> other;};
|
||||
typedef T value_type;
|
||||
|
||||
template <class U> struct rebind {typedef allocator<U> other;}; // deprecated in C++17, removed in C++20
|
||||
|
||||
typedef true_type propagate_on_container_move_assignment;
|
||||
typedef true_type is_always_equal;
|
||||
|
||||
constexpr allocator() noexcept; // constexpr in C++20
|
||||
constexpr allocator(const allocator&) noexcept; // constexpr in C++20
|
||||
template <class U>
|
||||
constexpr allocator(const allocator<U>&) noexcept; // constexpr in C++20
|
||||
~allocator();
|
||||
pointer address(reference x) const noexcept;
|
||||
const_pointer address(const_reference x) const noexcept;
|
||||
pointer allocate(size_type, allocator<void>::const_pointer hint = 0);
|
||||
void deallocate(pointer p, size_type n) noexcept;
|
||||
size_type max_size() const noexcept;
|
||||
pointer address(reference x) const noexcept; // deprecated in C++17, removed in C++20
|
||||
const_pointer address(const_reference x) const noexcept; // deprecated in C++17, removed in C++20
|
||||
T* allocate(size_t n, const void* hint); // deprecated in C++17, removed in C++20
|
||||
T* allocate(size_t n);
|
||||
void deallocate(T* p, size_t n) noexcept;
|
||||
size_type max_size() const noexcept; // deprecated in C++17, removed in C++20
|
||||
template<class U, class... Args>
|
||||
void construct(U* p, Args&&... args);
|
||||
void construct(U* p, Args&&... args); // deprecated in C++17, removed in C++20
|
||||
template <class U>
|
||||
void destroy(U* p);
|
||||
void destroy(U* p); // deprecated in C++17, removed in C++20
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
@@ -705,8 +712,9 @@ _ValueType __libcpp_acquire_load(_ValueType const* __value) {
|
||||
|
||||
template <class _Tp> class allocator;
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
template <>
|
||||
class _LIBCPP_TEMPLATE_VIS allocator<void>
|
||||
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<void>
|
||||
{
|
||||
public:
|
||||
typedef void* pointer;
|
||||
@@ -717,7 +725,7 @@ public:
|
||||
};
|
||||
|
||||
template <>
|
||||
class _LIBCPP_TEMPLATE_VIS allocator<const void>
|
||||
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 allocator<const void>
|
||||
{
|
||||
public:
|
||||
typedef const void* pointer;
|
||||
@@ -726,6 +734,7 @@ public:
|
||||
|
||||
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||
};
|
||||
#endif
|
||||
|
||||
// pointer_traits
|
||||
|
||||
@@ -832,16 +841,12 @@ struct __pointer_traits_difference_type<_Ptr, true>
|
||||
typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::difference_type type;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up, class = void>
|
||||
struct __has_rebind : false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __has_rebind
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Xp> static __two __test(...);
|
||||
template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_rebind<_Tp, _Up,
|
||||
typename __void_t<typename _Tp::template rebind<_Up> >::type> : true_type {};
|
||||
|
||||
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
|
||||
struct __pointer_traits_rebind
|
||||
@@ -1266,7 +1271,9 @@ struct __has_rebind_other
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Xp> static __two __test(...);
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0);
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
@@ -1280,7 +1287,9 @@ struct __has_rebind_other<_Tp, _Up, false>
|
||||
template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
|
||||
struct __allocator_traits_rebind
|
||||
{
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
@@ -1288,7 +1297,9 @@ struct __allocator_traits_rebind
|
||||
template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
|
||||
struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>
|
||||
{
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
typedef _LIBCPP_NODEBUG_TYPE typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
};
|
||||
|
||||
template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
|
||||
@@ -1355,10 +1366,12 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false>
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
|
||||
auto
|
||||
__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
|
||||
-> decltype((void)__a.allocate(__sz, __p), true_type());
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
|
||||
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
|
||||
auto
|
||||
@@ -1367,12 +1380,9 @@ __has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __
|
||||
|
||||
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
|
||||
struct __has_allocate_hint
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(_VSTD::__has_allocate_hint_test(declval<_Alloc>(),
|
||||
declval<_SizeType>(),
|
||||
declval<_ConstVoidPtr>())),
|
||||
true_type>::value>
|
||||
: decltype(_VSTD::__has_allocate_hint_test(declval<_Alloc>(),
|
||||
declval<_SizeType>(),
|
||||
declval<_ConstVoidPtr>()))
|
||||
{
|
||||
};
|
||||
|
||||
@@ -1388,31 +1398,32 @@ struct __has_allocate_hint
|
||||
|
||||
#if !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
template <class _Alloc, class _Tp, class ..._Args>
|
||||
decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(),
|
||||
_VSTD::declval<_Args>()...),
|
||||
true_type())
|
||||
__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args);
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
template <class _Alloc, class _Tp, class... _Args>
|
||||
auto
|
||||
__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&&... __args)
|
||||
-> decltype(__a.construct(__p, _VSTD::forward<_Args>(__args)...), true_type());
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
|
||||
template <class _Alloc, class _Pointer, class ..._Args>
|
||||
false_type
|
||||
__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args);
|
||||
auto
|
||||
__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args)
|
||||
-> false_type;
|
||||
|
||||
template <class _Alloc, class _Pointer, class ..._Args>
|
||||
struct __has_construct
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(_VSTD::__has_construct_test(declval<_Alloc>(),
|
||||
declval<_Pointer>(),
|
||||
declval<_Args>()...)),
|
||||
true_type>::value>
|
||||
: decltype(_VSTD::__has_construct_test(declval<_Alloc>(),
|
||||
declval<_Pointer>(),
|
||||
declval<_Args>()...))
|
||||
{
|
||||
};
|
||||
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
template <class _Alloc, class _Pointer>
|
||||
auto
|
||||
__has_destroy_test(_Alloc&& __a, _Pointer&& __p)
|
||||
-> decltype(__a.destroy(__p), true_type());
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
|
||||
template <class _Alloc, class _Pointer>
|
||||
auto
|
||||
@@ -1421,18 +1432,17 @@ __has_destroy_test(const _Alloc& __a, _Pointer&& __p)
|
||||
|
||||
template <class _Alloc, class _Pointer>
|
||||
struct __has_destroy
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(_VSTD::__has_destroy_test(declval<_Alloc>(),
|
||||
declval<_Pointer>())),
|
||||
true_type>::value>
|
||||
: decltype(_VSTD::__has_destroy_test(declval<_Alloc>(),
|
||||
declval<_Pointer>()))
|
||||
{
|
||||
};
|
||||
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
template <class _Alloc>
|
||||
auto
|
||||
__has_max_size_test(_Alloc&& __a)
|
||||
-> decltype(__a.max_size(), true_type());
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
|
||||
template <class _Alloc>
|
||||
auto
|
||||
@@ -1441,10 +1451,7 @@ __has_max_size_test(const volatile _Alloc& __a)
|
||||
|
||||
template <class _Alloc>
|
||||
struct __has_max_size
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(_VSTD::__has_max_size_test(declval<_Alloc&>())),
|
||||
true_type>::value>
|
||||
: decltype(_VSTD::__has_max_size_test(declval<_Alloc&>()))
|
||||
{
|
||||
};
|
||||
|
||||
@@ -1460,10 +1467,7 @@ __has_select_on_container_copy_construction_test(const volatile _Alloc& __a)
|
||||
|
||||
template <class _Alloc>
|
||||
struct __has_select_on_container_copy_construction
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>())),
|
||||
true_type>::value>
|
||||
: decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>()))
|
||||
{
|
||||
};
|
||||
|
||||
@@ -1755,7 +1759,11 @@ private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static pointer __allocate(allocator_type& __a, size_type __n,
|
||||
const_void_pointer __hint, true_type)
|
||||
{return __a.allocate(__n, __hint);}
|
||||
{
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
return __a.allocate(__n, __hint);
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static pointer __allocate(allocator_type& __a, size_type __n,
|
||||
const_void_pointer, false_type)
|
||||
@@ -1765,7 +1773,12 @@ private:
|
||||
template <class _Tp, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args)
|
||||
{__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
|
||||
{
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
__a.construct(__p, _VSTD::forward<_Args>(__args)...);
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
}
|
||||
|
||||
template <class _Tp, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
|
||||
@@ -1790,7 +1803,11 @@ private:
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __destroy(true_type, allocator_type& __a, _Tp* __p)
|
||||
{__a.destroy(__p);}
|
||||
{
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
__a.destroy(__p);
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
}
|
||||
template <class _Tp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void __destroy(false_type, allocator_type&, _Tp* __p)
|
||||
@@ -1800,7 +1817,12 @@ private:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT
|
||||
{return __a.max_size();}
|
||||
{
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
||||
return __a.max_size();
|
||||
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT
|
||||
{return numeric_limits<size_type>::max() / sizeof(value_type);}
|
||||
@@ -1831,19 +1853,22 @@ template <class _Tp>
|
||||
class _LIBCPP_TEMPLATE_VIS allocator
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
|
||||
|
||||
template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
|
||||
#endif
|
||||
|
||||
typedef _Tp value_type;
|
||||
|
||||
typedef true_type propagate_on_container_move_assignment;
|
||||
typedef true_type is_always_equal;
|
||||
|
||||
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
allocator() _NOEXCEPT {}
|
||||
|
||||
@@ -1851,25 +1876,39 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
allocator(const allocator<_Up>&) _NOEXCEPT {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
pointer address(reference __x) const _NOEXCEPT
|
||||
{return _VSTD::addressof(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
const_pointer address(const_reference __x) const _NOEXCEPT
|
||||
{return _VSTD::addressof(__x);}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
|
||||
#endif
|
||||
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _Tp* allocate(size_t __n)
|
||||
{
|
||||
if (__n > max_size())
|
||||
// TODO(mpark): Replace with `allocator_traits<allocator>::max_size(*this)`.
|
||||
if (__n > (size_t(~0) / sizeof(_Tp)))
|
||||
__throw_length_error("allocator<T>::allocate(size_t n)"
|
||||
" 'n' exceeds maximum supported size");
|
||||
return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
|
||||
return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) _NOEXCEPT
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
|
||||
_Tp* allocate(size_t __n, const void*) { return allocate(__n); }
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(_Tp* __p, size_t __n) _NOEXCEPT
|
||||
{_VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
{return size_type(~0) / sizeof(_Tp);}
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
template <class _Up, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
construct(_Up* __p, _Args&&... __args)
|
||||
{
|
||||
@@ -1928,26 +1967,30 @@ public:
|
||||
::new((void*)__p) _Tp(__a0, __a1);
|
||||
}
|
||||
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
_LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef const _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef const _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef const _Tp value_type;
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
|
||||
|
||||
template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
|
||||
#endif
|
||||
|
||||
typedef const _Tp value_type;
|
||||
|
||||
typedef true_type propagate_on_container_move_assignment;
|
||||
typedef true_type is_always_equal;
|
||||
|
||||
template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
allocator() _NOEXCEPT {}
|
||||
|
||||
@@ -1955,22 +1998,36 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
allocator(const allocator<_Up>&) _NOEXCEPT {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
const_pointer address(const_reference __x) const _NOEXCEPT
|
||||
{return _VSTD::addressof(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
|
||||
#endif
|
||||
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const _Tp* allocate(size_t __n)
|
||||
{
|
||||
if (__n > max_size())
|
||||
// TODO(mpark): Replace with `allocator_traits<allocator>::max_size(*this)`.
|
||||
if (__n > (size_t(~0) / sizeof(_Tp)))
|
||||
__throw_length_error("allocator<const T>::allocate(size_t n)"
|
||||
" 'n' exceeds maximum supported size");
|
||||
return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
|
||||
return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) _NOEXCEPT
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
|
||||
const _Tp* allocate(size_t __n, const void*) { return allocate(__n); }
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(const _Tp* __p, size_t __n)
|
||||
{_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
{return size_type(~0) / sizeof(_Tp);}
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
template <class _Up, class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
construct(_Up* __p, _Args&&... __args)
|
||||
{
|
||||
@@ -2029,7 +2086,8 @@ public:
|
||||
::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
|
||||
}
|
||||
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
_LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
|
||||
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
|
||||
@@ -12,6 +12,15 @@
|
||||
// pointer address(reference x) const;
|
||||
// const_pointer address(const_reference x) const;
|
||||
|
||||
// In C++20, parts of std::allocator<T> have been removed.
|
||||
// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// is defined before including <memory>, then removed members will be restored.
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// MODULES_DEFINES: _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// allocator:
|
||||
// pointer address(reference x) const;
|
||||
// const_pointer address(const_reference x) const;
|
||||
|
||||
// Deprecated in C++17
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// REQUIRES: verify-support
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
|
||||
#include <memory>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
int x = 0;
|
||||
std::allocator<int> a;
|
||||
|
||||
int* p = a.address(x); // expected-error{{'address' is deprecated}}
|
||||
(void)p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
// <memory>
|
||||
|
||||
// allocator:
|
||||
// T* allocate(size_t n, const void* hint);
|
||||
|
||||
// In C++20, parts of std::allocator<T> have been removed.
|
||||
// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// is defined before including <memory>, then removed members will be restored.
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// MODULES_DEFINES: _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::allocator<int> a;
|
||||
a.allocate(3, nullptr); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// allocator:
|
||||
// T* allocate(size_t n, const void* hint);
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// MODULES_DEFINES: _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
#include <cstddef> // for std::max_align_t
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "count_new.h"
|
||||
|
||||
|
||||
#ifdef TEST_HAS_NO_ALIGNED_ALLOCATION
|
||||
static const bool UsingAlignedNew = false;
|
||||
#else
|
||||
static const bool UsingAlignedNew = true;
|
||||
#endif
|
||||
|
||||
#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
|
||||
static const size_t MaxAligned = __STDCPP_DEFAULT_NEW_ALIGNMENT__;
|
||||
#else
|
||||
static const size_t MaxAligned = std::alignment_of<std::max_align_t>::value;
|
||||
#endif
|
||||
|
||||
static const size_t OverAligned = MaxAligned * 2;
|
||||
|
||||
|
||||
template <size_t Align>
|
||||
struct TEST_ALIGNAS(Align) AlignedType {
|
||||
char data;
|
||||
static int constructed;
|
||||
AlignedType() { ++constructed; }
|
||||
AlignedType(AlignedType const&) { ++constructed; }
|
||||
~AlignedType() { --constructed; }
|
||||
};
|
||||
template <size_t Align>
|
||||
int AlignedType<Align>::constructed = 0;
|
||||
|
||||
|
||||
template <size_t Align>
|
||||
void test_aligned() {
|
||||
typedef AlignedType<Align> T;
|
||||
T::constructed = 0;
|
||||
globalMemCounter.reset();
|
||||
std::allocator<T> a;
|
||||
const bool IsOverAlignedType = Align > MaxAligned;
|
||||
const bool ExpectAligned = IsOverAlignedType && UsingAlignedNew;
|
||||
{
|
||||
globalMemCounter.last_new_size = 0;
|
||||
globalMemCounter.last_new_align = 0;
|
||||
T* volatile ap2 = a.allocate(11, (const void*)5);
|
||||
DoNotOptimize(ap2);
|
||||
assert(globalMemCounter.checkOutstandingNewEq(1));
|
||||
assert(globalMemCounter.checkNewCalledEq(1));
|
||||
assert(globalMemCounter.checkAlignedNewCalledEq(ExpectAligned));
|
||||
assert(globalMemCounter.checkLastNewSizeEq(11 * sizeof(T)));
|
||||
assert(globalMemCounter.checkLastNewAlignEq(ExpectAligned ? Align : 0));
|
||||
assert(T::constructed == 0);
|
||||
globalMemCounter.last_delete_align = 0;
|
||||
a.deallocate(ap2, 11);
|
||||
DoNotOptimize(ap2);
|
||||
assert(globalMemCounter.checkOutstandingNewEq(0));
|
||||
assert(globalMemCounter.checkDeleteCalledEq(1));
|
||||
assert(globalMemCounter.checkAlignedDeleteCalledEq(ExpectAligned));
|
||||
assert(globalMemCounter.checkLastDeleteAlignEq(ExpectAligned ? Align : 0));
|
||||
assert(T::constructed == 0);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
test_aligned<1>();
|
||||
test_aligned<2>();
|
||||
test_aligned<4>();
|
||||
test_aligned<8>();
|
||||
test_aligned<16>();
|
||||
test_aligned<MaxAligned>();
|
||||
test_aligned<OverAligned>();
|
||||
test_aligned<OverAligned * 2>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// allocator:
|
||||
// T* allocate(size_t n, const void* hint);
|
||||
|
||||
// Deprecated in C++17
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// REQUIERS: verify-support
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
|
||||
#include <memory>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::allocator<int> a;
|
||||
TEST_IGNORE_NODISCARD a.allocate(3, nullptr); // expected-error {{'allocate' is deprecated}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -11,6 +11,15 @@
|
||||
// allocator:
|
||||
// template <class... Args> void construct(pointer p, Args&&... args);
|
||||
|
||||
// In C++20, parts of std::allocator<T> have been removed.
|
||||
// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// is defined before including <memory>, then removed members will be restored.
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// MODULES_DEFINES: _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
@@ -11,6 +11,15 @@
|
||||
// allocator:
|
||||
// size_type max_size() const throw();
|
||||
|
||||
// In C++20, parts of std::allocator<T> have been removed.
|
||||
// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// is defined before including <memory>, then removed members will be restored.
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// MODULES_DEFINES: _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <memory>
|
||||
#include <limits>
|
||||
#include <cstddef>
|
||||
@@ -0,0 +1,51 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// check nested types:
|
||||
|
||||
// template <class T>
|
||||
// class allocator
|
||||
// {
|
||||
// public:
|
||||
// typedef size_t size_type;
|
||||
// typedef ptrdiff_t difference_type;
|
||||
// typedef T* pointer;
|
||||
// typedef const T* const_pointer;
|
||||
// typedef typename add_lvalue_reference<T>::type reference;
|
||||
// typedef typename add_lvalue_reference<const T>::type const_reference;
|
||||
//
|
||||
// template <class U> struct rebind {typedef allocator<U> other;};
|
||||
// ...
|
||||
// };
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// MODULES_DEFINES: _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::difference_type, std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::pointer, char*>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::const_pointer, const char*>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::reference, char&>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::const_reference, const char&>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::rebind<int>::other,
|
||||
std::allocator<int> >::value), "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
|
||||
// check nested types:
|
||||
|
||||
// template <class T>
|
||||
// class allocator
|
||||
// {
|
||||
// public:
|
||||
// typedef size_t size_type;
|
||||
// typedef ptrdiff_t difference_type;
|
||||
// typedef T* pointer;
|
||||
// typedef const T* const_pointer;
|
||||
// typedef typename add_lvalue_reference<T>::type reference;
|
||||
// typedef typename add_lvalue_reference<const T>::type const_reference;
|
||||
//
|
||||
// template <class U> struct rebind {typedef allocator<U> other;};
|
||||
// ...
|
||||
// };
|
||||
|
||||
// Deprecated in C++17
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// REQUIRES: verify-support
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
|
||||
#include <memory>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
typedef std::allocator<char>::size_type AST; // expected-error{{'size_type' is deprecated}}
|
||||
typedef std::allocator<char>::difference_type ADT; // expected-error{{'difference_type' is deprecated}}
|
||||
typedef std::allocator<char>::pointer AP; // expected-error{{'pointer' is deprecated}}
|
||||
typedef std::allocator<char>::const_pointer ACP; // expected-error{{'const_pointer' is deprecated}}
|
||||
typedef std::allocator<char>::reference AR; // expected-error{{'reference' is deprecated}}
|
||||
typedef std::allocator<char>::const_reference ACR; // expected-error{{'const_reference' is deprecated}}
|
||||
typedef std::allocator<char>::rebind<int>::other ARO; // expected-error{{'rebind<int>' is deprecated}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -19,6 +19,11 @@
|
||||
// template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||
// };
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
// MODULES_DEFINES: _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <memory>
|
||||
//
|
||||
// template <>
|
||||
// class allocator<void>
|
||||
// {
|
||||
// public:
|
||||
// typedef void* pointer;
|
||||
// typedef const void* const_pointer;
|
||||
// typedef void value_type;
|
||||
//
|
||||
// template <class _Up> struct rebind {typedef allocator<_Up> other;};
|
||||
// };
|
||||
//
|
||||
// Deprecated in C++17
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// REQUIRES: verify-support
|
||||
|
||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
|
||||
#include <memory>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
typedef std::allocator<void>::pointer AP; // expected-error{{'allocator<void>' is deprecated}}
|
||||
typedef std::allocator<void>::const_pointer ACP; // expected-error{{'allocator<void>' is deprecated}}
|
||||
typedef std::allocator<void>::rebind<int>::other ARO; // expected-error{{'allocator<void>' is deprecated}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ int main(int, char**) {
|
||||
std::tuple<Base const&, int> t(ct, 42); // expected-note {{requested here}}
|
||||
}
|
||||
{
|
||||
std::allocator<void> alloc;
|
||||
std::allocator<int> alloc;
|
||||
std::tuple<std::string &&> t2("hello"); // expected-note {{requested here}}
|
||||
std::tuple<std::string &&> t3(std::allocator_arg, alloc, "hello"); // expected-note {{requested here}}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
// };
|
||||
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <deque>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
// typedef typename allocator_type::pointer pointer;
|
||||
// typedef typename allocator_type::const_pointer const_pointer;
|
||||
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <list>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
// };
|
||||
|
||||
#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
|
||||
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
|
||||
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ex = std::experimental::pmr;
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
typedef ex::resource_adaptor<std::allocator<void>> R;
|
||||
typedef ex::resource_adaptor<std::allocator<int>> R;
|
||||
typedef ex::resource_adaptor<std::allocator<long>> R2;
|
||||
static_assert(std::is_same<R, R2>::value, "");
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ int main(int, char**)
|
||||
assert(A::count == 1);
|
||||
assert(f.target<A>() == nullptr);
|
||||
assert(f.target<Ref>());
|
||||
std::function<int(int)> f2(std::allocator_arg, std::allocator<void>{},
|
||||
std::function<int(int)> f2(std::allocator_arg, std::allocator<int>{},
|
||||
std::move(f));
|
||||
assert(A::count == 1);
|
||||
assert(f2.target<A>() == nullptr);
|
||||
@@ -99,7 +99,7 @@ int main(int, char**)
|
||||
std::function<int(int)> f(p);
|
||||
assert(f.target<A>() == nullptr);
|
||||
assert(f.target<Ptr>());
|
||||
std::function<int(int)> f2(std::allocator_arg, std::allocator<void>(),
|
||||
std::function<int(int)> f2(std::allocator_arg, std::allocator<int>(),
|
||||
std::move(f));
|
||||
assert(f2.target<A>() == nullptr);
|
||||
assert(f2.target<Ptr>());
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
// <memory>
|
||||
|
||||
// allocator:
|
||||
// pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
// T* allocate(size_t n);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
@@ -23,7 +23,6 @@ int main(int, char**)
|
||||
{
|
||||
std::allocator<int> a;
|
||||
a.allocate(3); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
a.allocate(3, nullptr); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// <memory>
|
||||
|
||||
// allocator:
|
||||
// pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
|
||||
// T* allocate(size_t n);
|
||||
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
@@ -75,27 +75,6 @@ void test_aligned() {
|
||||
assert(globalMemCounter.checkLastDeleteAlignEq(ExpectAligned ? Align : 0));
|
||||
assert(T::constructed == 0);
|
||||
}
|
||||
globalMemCounter.reset();
|
||||
{
|
||||
globalMemCounter.last_new_size = 0;
|
||||
globalMemCounter.last_new_align = 0;
|
||||
T* volatile ap2 = a.allocate(11, (const void*)5);
|
||||
DoNotOptimize(ap2);
|
||||
assert(globalMemCounter.checkOutstandingNewEq(1));
|
||||
assert(globalMemCounter.checkNewCalledEq(1));
|
||||
assert(globalMemCounter.checkAlignedNewCalledEq(ExpectAligned));
|
||||
assert(globalMemCounter.checkLastNewSizeEq(11 * sizeof(T)));
|
||||
assert(globalMemCounter.checkLastNewAlignEq(ExpectAligned ? Align : 0));
|
||||
assert(T::constructed == 0);
|
||||
globalMemCounter.last_delete_align = 0;
|
||||
a.deallocate(ap2, 11);
|
||||
DoNotOptimize(ap2);
|
||||
assert(globalMemCounter.checkOutstandingNewEq(0));
|
||||
assert(globalMemCounter.checkDeleteCalledEq(1));
|
||||
assert(globalMemCounter.checkAlignedDeleteCalledEq(ExpectAligned));
|
||||
assert(globalMemCounter.checkLastDeleteAlignEq(ExpectAligned ? Align : 0));
|
||||
assert(T::constructed == 0);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char**) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// <memory>
|
||||
|
||||
// allocator:
|
||||
// pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
|
||||
// T* allocate(size_t n);
|
||||
|
||||
// When back-deploying to macosx10.7, the RTTI for exception classes
|
||||
// incorrectly provided by libc++.dylib is mixed with the one in
|
||||
@@ -37,9 +37,11 @@ template <typename T>
|
||||
void test()
|
||||
{
|
||||
// Bug 26812 -- allocating too large
|
||||
std::allocator<T> a;
|
||||
test_max<T> (a.max_size() + 1); // just barely too large
|
||||
test_max<T> (a.max_size() * 2); // significantly too large
|
||||
typedef std::allocator<T> A;
|
||||
typedef std::allocator_traits<A> AT;
|
||||
A a;
|
||||
test_max<T> (AT::max_size(a) + 1); // just barely too large
|
||||
test_max<T> (AT::max_size(a) * 2); // significantly too large
|
||||
test_max<T> (((size_t) -1) / sizeof(T) + 1); // multiply will overflow
|
||||
test_max<T> ((size_t) -1); // way too large
|
||||
}
|
||||
|
||||
@@ -14,16 +14,10 @@
|
||||
// class allocator
|
||||
// {
|
||||
// public:
|
||||
// typedef size_t size_type;
|
||||
// typedef ptrdiff_t difference_type;
|
||||
// typedef T* pointer;
|
||||
// typedef const T* const_pointer;
|
||||
// typedef typename add_lvalue_reference<T>::type reference;
|
||||
// typedef typename add_lvalue_reference<const T>::type const_reference;
|
||||
// typedef T value_type;
|
||||
// typedef true_type is_always_equal;
|
||||
// typedef T value_type;
|
||||
//
|
||||
// template <class U> struct rebind {typedef allocator<U> other;};
|
||||
// typedef true_type propagate_on_container_move_assignment;
|
||||
// typedef true_type is_always_equal;
|
||||
// ...
|
||||
// };
|
||||
|
||||
@@ -35,17 +29,12 @@
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::difference_type, std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::pointer, char*>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::const_pointer, const char*>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::value_type, char>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::reference, char&>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::const_reference, const char&>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::rebind<int>::other,
|
||||
std::allocator<int> >::value), "");
|
||||
|
||||
static_assert((std::is_same<std::allocator< char>::is_always_equal, std::true_type>::value), "");
|
||||
static_assert((std::is_same<std::allocator<char>::propagate_on_container_move_assignment, std::true_type>::value), "");
|
||||
LIBCPP_STATIC_ASSERT((std::is_same<std::allocator<const char>::propagate_on_container_move_assignment, std::true_type>::value), "");
|
||||
|
||||
static_assert((std::is_same<std::allocator<char>::is_always_equal, std::true_type>::value), "");
|
||||
LIBCPP_STATIC_ASSERT((std::is_same<std::allocator<const char>::is_always_equal, std::true_type>::value), "");
|
||||
|
||||
std::allocator<char> a;
|
||||
|
||||
@@ -86,7 +86,7 @@ void compile_tests() {
|
||||
}
|
||||
|
||||
void allocator_tests() {
|
||||
std::allocator<void> alloc;
|
||||
std::allocator<int> alloc;
|
||||
int x = 42;
|
||||
{
|
||||
std::tuple<int&> t(std::ref(x));
|
||||
|
||||
@@ -71,22 +71,22 @@ int main(int, char**) {
|
||||
{
|
||||
static_assert(std::is_constructible<
|
||||
std::tuple<A>,
|
||||
std::allocator_arg_t, std::allocator<void>,
|
||||
std::allocator_arg_t, std::allocator<int>,
|
||||
std::tuple<A> const&
|
||||
>::value, "");
|
||||
static_assert(std::is_constructible<
|
||||
std::tuple<A>,
|
||||
std::allocator_arg_t, std::allocator<void>,
|
||||
std::allocator_arg_t, std::allocator<int>,
|
||||
std::tuple<A> &&
|
||||
>::value, "");
|
||||
static_assert(std::is_constructible<
|
||||
std::tuple<ExplicitA>,
|
||||
std::allocator_arg_t, std::allocator<void>,
|
||||
std::allocator_arg_t, std::allocator<int>,
|
||||
std::tuple<ExplicitA> const&
|
||||
>::value, "");
|
||||
static_assert(std::is_constructible<
|
||||
std::tuple<ExplicitA>,
|
||||
std::allocator_arg_t, std::allocator<void>,
|
||||
std::allocator_arg_t, std::allocator<int>,
|
||||
std::tuple<ExplicitA> &&
|
||||
>::value, "");
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ struct Explicit {
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
std::tuple<Explicit> t{std::allocator_arg, std::allocator<void>{}, 42};
|
||||
std::tuple<Explicit> t{std::allocator_arg, std::allocator<int>{}, 42};
|
||||
assert(std::get<0>(t).value == 42);
|
||||
}
|
||||
{
|
||||
|
||||
@@ -26,13 +26,13 @@ struct ExplicitCopy {
|
||||
|
||||
std::tuple<ExplicitCopy> const_explicit_copy_test() {
|
||||
const ExplicitCopy e(42);
|
||||
return {std::allocator_arg, std::allocator<void>{}, e};
|
||||
return {std::allocator_arg, std::allocator<int>{}, e};
|
||||
// expected-error@-1 {{chosen constructor is explicit in copy-initialization}}
|
||||
}
|
||||
|
||||
std::tuple<ExplicitCopy> non_const_explicity_copy_test() {
|
||||
ExplicitCopy e(42);
|
||||
return {std::allocator_arg, std::allocator<void>{}, e};
|
||||
return {std::allocator_arg, std::allocator<int>{}, e};
|
||||
// expected-error@-1 {{chosen constructor is explicit in copy-initialization}}
|
||||
}
|
||||
int main(int, char**)
|
||||
|
||||
@@ -33,19 +33,19 @@ struct ImplicitCopy {
|
||||
// copy conversions in return value expressions.
|
||||
std::tuple<ImplicitCopy> testImplicitCopy1() {
|
||||
ImplicitCopy i(42);
|
||||
return {std::allocator_arg, std::allocator<void>{}, i};
|
||||
return {std::allocator_arg, std::allocator<int>{}, i};
|
||||
}
|
||||
|
||||
std::tuple<ImplicitCopy> testImplicitCopy2() {
|
||||
const ImplicitCopy i(42);
|
||||
return {std::allocator_arg, std::allocator<void>{}, i};
|
||||
return {std::allocator_arg, std::allocator<int>{}, i};
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
// check that the literal '0' can implicitly initialize a stored pointer.
|
||||
std::tuple<int*> t = {std::allocator_arg, std::allocator<void>{}, 0};
|
||||
std::tuple<int*> t = {std::allocator_arg, std::allocator<int>{}, 0};
|
||||
}
|
||||
{
|
||||
std::tuple<int> t(std::allocator_arg, A1<int>(), 3);
|
||||
|
||||
@@ -26,13 +26,13 @@ struct ExplicitCopy {
|
||||
|
||||
std::tuple<ExplicitCopy> const_explicit_copy_test() {
|
||||
const std::tuple<int> t1(42);
|
||||
return {std::allocator_arg, std::allocator<void>{}, t1};
|
||||
return {std::allocator_arg, std::allocator<int>{}, t1};
|
||||
// expected-error@-1 {{chosen constructor is explicit in copy-initialization}}
|
||||
}
|
||||
|
||||
std::tuple<ExplicitCopy> non_const_explicit_copy_test() {
|
||||
std::tuple<int> t1(42);
|
||||
return {std::allocator_arg, std::allocator<void>{}, t1};
|
||||
return {std::allocator_arg, std::allocator<int>{}, t1};
|
||||
// expected-error@-1 {{chosen constructor is explicit in copy-initialization}}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,12 +79,12 @@ int main(int, char**)
|
||||
}
|
||||
{
|
||||
const std::tuple<int> t1(42);
|
||||
std::tuple<Explicit> t2{std::allocator_arg, std::allocator<void>{}, t1};
|
||||
std::tuple<Explicit> t2{std::allocator_arg, std::allocator<int>{}, t1};
|
||||
assert(std::get<0>(t2).value == 42);
|
||||
}
|
||||
{
|
||||
const std::tuple<int> t1(42);
|
||||
std::tuple<Implicit> t2 = {std::allocator_arg, std::allocator<void>{}, t1};
|
||||
std::tuple<Implicit> t2 = {std::allocator_arg, std::allocator<int>{}, t1};
|
||||
assert(std::get<0>(t2).value == 42);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ struct ExplicitCopy {
|
||||
|
||||
std::tuple<ExplicitCopy> explicit_move_test() {
|
||||
std::tuple<int> t1(42);
|
||||
return {std::allocator_arg, std::allocator<void>{}, std::move(t1)};
|
||||
return {std::allocator_arg, std::allocator<int>{}, std::move(t1)};
|
||||
// expected-error@-1 {{chosen constructor is explicit in copy-initialization}}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,12 +93,12 @@ int main(int, char**)
|
||||
}
|
||||
{
|
||||
std::tuple<int> t1(42);
|
||||
std::tuple<Explicit> t2{std::allocator_arg, std::allocator<void>{}, std::move(t1)};
|
||||
std::tuple<Explicit> t2{std::allocator_arg, std::allocator<int>{}, std::move(t1)};
|
||||
assert(std::get<0>(t2).value == 42);
|
||||
}
|
||||
{
|
||||
std::tuple<int> t1(42);
|
||||
std::tuple<Implicit> t2 = {std::allocator_arg, std::allocator<void>{}, std::move(t1)};
|
||||
std::tuple<Implicit> t2 = {std::allocator_arg, std::allocator<int>{}, std::move(t1)};
|
||||
assert(std::get<0>(t2).value == 42);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ struct move_only_large final {
|
||||
template <class Elem>
|
||||
void test_sfinae() {
|
||||
using Tup = std::tuple<Elem>;
|
||||
using Alloc = std::allocator<void>;
|
||||
using Alloc = std::allocator<int>;
|
||||
using Tag = std::allocator_arg_t;
|
||||
// special members
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user