Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions libcxx/include/__memory/temp_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <__config>
#include <__memory/addressof.h>
#include <__memory/allocator_traits.h>
#include <__type_traits/aligned_storage.h>
#include <__utility/forward.h>

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

#ifdef _LIBCPP_CXX03_LANG
typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
_ALIGNAS_TYPE(_Tp) char __v[sizeof(_Tp)];
#else
union {
_Tp __v;
Expand Down
10 changes: 4 additions & 6 deletions libcxx/include/any
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ namespace std {
# include <__memory/unique_ptr.h>
# include <__type_traits/add_cv_quals.h>
# include <__type_traits/add_pointer.h>
# include <__type_traits/aligned_storage.h>
# include <__type_traits/conditional.h>
# include <__type_traits/decay.h>
# include <__type_traits/enable_if.h>
Expand Down Expand Up @@ -148,14 +147,13 @@ template <class _ValueType>
_LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any*) _NOEXCEPT;

namespace __any_imp {
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
using _Buffer _LIBCPP_NODEBUG = aligned_storage_t<3 * sizeof(void*), alignof(void*)>;
_LIBCPP_SUPPRESS_DEPRECATED_POP
inline constexpr size_t __small_buffer_size = 3 * sizeof(void*);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the previous code easier to read since we did sizeof(_Buffer) and alignof(_Buffer) below. What would you think of using _Buffer = alignas(alignment) char [size] instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't put alignas on an alias.

inline constexpr size_t __small_buffer_alignment = alignof(void*);

template <class _Tp>
using _IsSmallObject _LIBCPP_NODEBUG =
integral_constant<bool,
sizeof(_Tp) <= sizeof(_Buffer) && alignof(_Buffer) % alignof(_Tp) == 0 &&
sizeof(_Tp) <= __small_buffer_size && alignof(_Tp) <= __small_buffer_alignment &&
is_nothrow_move_constructible<_Tp>::value >;

enum class _Action { _Destroy, _Copy, _Move, _Get, _TypeInfo };
Expand Down Expand Up @@ -285,7 +283,7 @@ private:
union _Storage {
_LIBCPP_HIDE_FROM_ABI constexpr _Storage() : __ptr(nullptr) {}
void* __ptr;
__any_imp::_Buffer __buf;
alignas(__any_imp::__small_buffer_alignment) char __buf[__any_imp::__small_buffer_size];
};

_LIBCPP_HIDE_FROM_ABI void*
Expand Down
5 changes: 1 addition & 4 deletions libcxx/include/future
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,9 @@ inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _P
template <class _Rp>
class _LIBCPP_HIDDEN __assoc_state : public __assoc_sub_state {
typedef __assoc_sub_state base;
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
typedef typename aligned_storage<sizeof(_Rp), _LIBCPP_ALIGNOF(_Rp)>::type _Up;
_LIBCPP_SUPPRESS_DEPRECATED_POP

protected:
_Up __value_;
_ALIGNAS_TYPE(_Rp) char __value_[sizeof(_Rp)];

_LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override;

Expand Down
Loading