forked from boostorg/smart_ptr
Add sp_type_identity
This commit is contained in:
@@ -32,6 +32,13 @@ template<class T> struct sp_is_unbounded_array< T[] >: std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
// std::type_identity (C++20)
|
||||
|
||||
template<class T> struct sp_type_identity
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
@@ -427,3 +427,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 ;
|
||||
|
31
test/sp_type_identity_test.cpp
Normal file
31
test/sp_type_identity_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// 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_trait.hpp>
|
||||
|
||||
struct X;
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::detail::sp_type_identity;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<void>::type, void );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<int>::type, int );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<X>::type, X );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<void const>::type, void const );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<int const>::type, int const );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<X const>::type, X const );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<void(int, X)>::type, void(int, X) );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<int[]>::type, int[] );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<X[]>::type, X[] );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<int[1]>::type, int[1] );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<X[2]>::type, X[2] );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user