mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-29 20:37:13 +02:00
Add sp_type_with_alignment
This commit is contained in:
@ -39,6 +39,16 @@ template<class T> struct sp_type_identity
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// boost::type_with_alignment
|
||||
|
||||
template<std::size_t A> struct sp_type_with_alignment
|
||||
{
|
||||
struct alignas(A) type
|
||||
{
|
||||
unsigned char padding[ A ];
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
@ -428,3 +428,4 @@ run sp_move_only_deleter.cpp ;
|
||||
run sp_is_bounded_array_test.cpp ;
|
||||
run sp_is_unbounded_array_test.cpp ;
|
||||
run sp_type_identity_test.cpp ;
|
||||
run sp_type_with_alignment_test.cpp ;
|
||||
|
18
test/sp_type_with_alignment_test.cpp
Normal file
18
test/sp_type_with_alignment_test.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::detail::sp_type_with_alignment;
|
||||
|
||||
BOOST_TEST_EQ( alignof( sp_type_with_alignment<1>::type ), 1 );
|
||||
BOOST_TEST_EQ( alignof( sp_type_with_alignment<2>::type ), 2 );
|
||||
BOOST_TEST_EQ( alignof( sp_type_with_alignment<4>::type ), 4 );
|
||||
BOOST_TEST_EQ( alignof( sp_type_with_alignment<8>::type ), 8 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user