[libcxx-commits] [libcxx] 2404ed0 - [libc++] NFC: Collocate C++20 removed members of std::allocator
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 22 14:40:28 PDT 2020
Author: Louis Dionne
Date: 2020-09-22T17:40:14-04:00
New Revision: 2404ed02025c210c707a856f69604ef20083dcbb
URL: https://github.com/llvm/llvm-project/commit/2404ed02025c210c707a856f69604ef20083dcbb
DIFF: https://github.com/llvm/llvm-project/commit/2404ed02025c210c707a856f69604ef20083dcbb.diff
LOG: [libc++] NFC: Collocate C++20 removed members of std::allocator
Added:
Modified:
libcxx/include/memory
Removed:
################################################################################
diff --git a/libcxx/include/memory b/libcxx/include/memory
index add0cc3e73dd..112ee9d4462c 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -1660,68 +1660,72 @@ template <class _Tp>
class _LIBCPP_TEMPLATE_VIS allocator
{
public:
- typedef size_t size_type;
- typedef ptr
diff _t
diff erence_type;
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _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;
+ typedef size_t size_type;
+ typedef ptr
diff _t
diff erence_type;
+ typedef _Tp value_type;
+ typedef true_type propagate_on_container_move_assignment;
+ typedef true_type is_always_equal;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator() _NOEXCEPT {}
+ allocator() _NOEXCEPT { }
template <class _Up>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator(const allocator<_Up>&) _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_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- const_pointer address(const_reference __x) const _NOEXCEPT
- {return _VSTD::addressof(__x);}
-#endif
+ allocator(const allocator<_Up>&) _NOEXCEPT { }
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- _Tp* allocate(size_t __n)
- {
+ _Tp* allocate(size_t __n) {
if (__n > allocator_traits<allocator>::max_size(*this))
__throw_length_error("allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
- }
-
-#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 _LIBCPP_CONSTEXPR_AFTER_CXX17
- void deallocate(_Tp* __p, size_t __n) _NOEXCEPT
- {_VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
+ void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
+ _VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ }
+ // C++20 Removed members
#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);}
+ _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;
+ };
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ pointer address(reference __x) const _NOEXCEPT {
+ return _VSTD::addressof(__x);
+ }
+ _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 _LIBCPP_DEPRECATED_IN_CXX17
+ _Tp* allocate(size_t __n, const void*) {
+ return allocate(__n);
+ }
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
+ return size_type(~0) / sizeof(_Tp);
+ }
template <class _Up, class... _Args>
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- void
- construct(_Up* __p, _Args&&... __args)
- {
- ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
- }
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void construct(_Up* __p, _Args&&... __args) {
+ ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+ }
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void destroy(pointer __p) {
+ __p->~_Tp();
+ }
#endif
};
@@ -1729,66 +1733,68 @@ template <class _Tp>
class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
{
public:
- typedef size_t size_type;
- typedef ptr
diff _t
diff erence_type;
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _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;
+ typedef size_t size_type;
+ typedef ptr
diff _t
diff erence_type;
+ typedef const _Tp value_type;
+ typedef true_type propagate_on_container_move_assignment;
+ typedef true_type is_always_equal;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator() _NOEXCEPT {}
+ allocator() _NOEXCEPT { }
template <class _Up>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator(const allocator<_Up>&) _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);}
-#endif
+ allocator(const allocator<_Up>&) _NOEXCEPT { }
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- const _Tp* allocate(size_t __n)
- {
+ const _Tp* allocate(size_t __n) {
if (__n > allocator_traits<allocator>::max_size(*this))
__throw_length_error("allocator<const T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
}
-#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 _LIBCPP_CONSTEXPR_AFTER_CXX17
- void deallocate(const _Tp* __p, size_t __n)
- {_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
+ void deallocate(const _Tp* __p, size_t __n) {
+ _VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ }
+ // C++20 Removed members
#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);}
+ _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;
+ };
+
+ _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 _LIBCPP_DEPRECATED_IN_CXX17
+ const _Tp* allocate(size_t __n, const void*) {
+ return allocate(__n);
+ }
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
+ return size_type(~0) / sizeof(_Tp);
+ }
template <class _Up, class... _Args>
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- void
- construct(_Up* __p, _Args&&... __args)
- {
- ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
- }
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void construct(_Up* __p, _Args&&... __args) {
+ ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+ }
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void destroy(pointer __p) {
+ __p->~_Tp();
+ }
#endif
};
More information about the libcxx-commits
mailing list