From 90fd5a1fc9c4b6bee6e8dc4916f7b7a9b3b0e246 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 6 Oct 2024 19:54:45 +0300 Subject: [PATCH] Add detail/sp_type_traits.hpp, sp_is_bounded_array --- .../boost/smart_ptr/detail/sp_type_traits.hpp | 28 +++++++++++++++++++ test/Jamfile | 2 ++ test/sp_is_bounded_array_test.cpp | 27 ++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 include/boost/smart_ptr/detail/sp_type_traits.hpp create mode 100644 test/sp_is_bounded_array_test.cpp 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(); +}