diff --git a/include/boost/smart_ptr/detail/sp_type_traits.hpp b/include/boost/smart_ptr/detail/sp_type_traits.hpp new file mode 100644 index 0000000..1437c7b --- /dev/null +++ b/include/boost/smart_ptr/detail/sp_type_traits.hpp @@ -0,0 +1,28 @@ +#ifndef BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED + +// Copyright 2024 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include + +namespace boost +{ +namespace detail +{ + +// std::is_bounded_array (C++20) + +template struct sp_is_bounded_array: std::false_type +{ +}; + +template struct sp_is_bounded_array< T[N] >: std::true_type +{ +}; + +} // namespace detail +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED diff --git a/test/Jamfile b/test/Jamfile index 8c21bf7..3de1ebc 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -424,3 +424,5 @@ run sp_unordered_test.cpp ; run sp_unique_ptr_test2.cpp ; run sp_move_only_deleter.cpp ; + +run sp_is_bounded_array_test.cpp ; diff --git a/test/sp_is_bounded_array_test.cpp b/test/sp_is_bounded_array_test.cpp new file mode 100644 index 0000000..c861cce --- /dev/null +++ b/test/sp_is_bounded_array_test.cpp @@ -0,0 +1,27 @@ +// Copyright 2024 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +struct X; + +int main() +{ + using boost::detail::sp_is_bounded_array; + + BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array )); + BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array )); + BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array )); + + BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array )); + BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array )); + + BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array )); + BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array )); + BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array )); + BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array )); + + return boost::report_errors(); +}