Skip to content

Commit 6dae88f

Browse files
committed
[libc++] Remove some of the uses of aligned_storage inside the library
1 parent 1098a5c commit 6dae88f

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

libcxx/include/__memory/temp_value.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <__config>
1313
#include <__memory/addressof.h>
1414
#include <__memory/allocator_traits.h>
15-
#include <__type_traits/aligned_storage.h>
1615
#include <__utility/forward.h>
1716

1817
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -26,7 +25,7 @@ struct __temp_value {
2625
typedef allocator_traits<_Alloc> _Traits;
2726

2827
#ifdef _LIBCPP_CXX03_LANG
29-
typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
28+
_ALIGNAS_TYPE(_Tp) char __v[sizeof(_Tp)];
3029
#else
3130
union {
3231
_Tp __v;

libcxx/include/any

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ namespace std {
9090
# include <__memory/unique_ptr.h>
9191
# include <__type_traits/add_cv_quals.h>
9292
# include <__type_traits/add_pointer.h>
93-
# include <__type_traits/aligned_storage.h>
9493
# include <__type_traits/conditional.h>
9594
# include <__type_traits/decay.h>
9695
# include <__type_traits/enable_if.h>
@@ -148,14 +147,13 @@ template <class _ValueType>
148147
_LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any*) _NOEXCEPT;
149148

150149
namespace __any_imp {
151-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
152-
using _Buffer _LIBCPP_NODEBUG = aligned_storage_t<3 * sizeof(void*), alignof(void*)>;
153-
_LIBCPP_SUPPRESS_DEPRECATED_POP
150+
inline constexpr size_t __small_buffer_size = 3 * sizeof(void*);
151+
inline constexpr size_t __small_buffer_alignment = alignof(void*);
154152

155153
template <class _Tp>
156154
using _IsSmallObject _LIBCPP_NODEBUG =
157155
integral_constant<bool,
158-
sizeof(_Tp) <= sizeof(_Buffer) && alignof(_Buffer) % alignof(_Tp) == 0 &&
156+
sizeof(_Tp) <= __small_buffer_size && alignof(_Tp) <= __small_buffer_alignment &&
159157
is_nothrow_move_constructible<_Tp>::value >;
160158

161159
enum class _Action { _Destroy, _Copy, _Move, _Get, _TypeInfo };
@@ -285,7 +283,7 @@ private:
285283
union _Storage {
286284
_LIBCPP_HIDE_FROM_ABI constexpr _Storage() : __ptr(nullptr) {}
287285
void* __ptr;
288-
__any_imp::_Buffer __buf;
286+
alignas(__any_imp::__small_buffer_alignment) char __buf[__any_imp::__small_buffer_size];
289287
};
290288

291289
_LIBCPP_HIDE_FROM_ABI void*

libcxx/include/future

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,9 @@ inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _P
583583
template <class _Rp>
584584
class _LIBCPP_HIDDEN __assoc_state : public __assoc_sub_state {
585585
typedef __assoc_sub_state base;
586-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
587-
typedef typename aligned_storage<sizeof(_Rp), _LIBCPP_ALIGNOF(_Rp)>::type _Up;
588-
_LIBCPP_SUPPRESS_DEPRECATED_POP
589586

590587
protected:
591-
_Up __value_;
588+
_ALIGNAS_TYPE(_Rp) char __value_[sizeof(_Rp)];
592589

593590
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override;
594591

0 commit comments

Comments
 (0)