Skip to content

Commit 90fd5a1

Browse files
committed
Add detail/sp_type_traits.hpp, sp_is_bounded_array
1 parent 0bedddb commit 90fd5a1

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED
2+
#define BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED
3+
4+
// Copyright 2024 Peter Dimov
5+
// Distributed under the Boost Software License, Version 1.0.
6+
// https://www.boost.org/LICENSE_1_0.txt
7+
8+
#include <type_traits>
9+
10+
namespace boost
11+
{
12+
namespace detail
13+
{
14+
15+
// std::is_bounded_array (C++20)
16+
17+
template<class T> struct sp_is_bounded_array: std::false_type
18+
{
19+
};
20+
21+
template<class T, std::size_t N> struct sp_is_bounded_array< T[N] >: std::true_type
22+
{
23+
};
24+
25+
} // namespace detail
26+
} // namespace boost
27+
28+
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED

test/Jamfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,5 @@ run sp_unordered_test.cpp ;
424424

425425
run sp_unique_ptr_test2.cpp ;
426426
run sp_move_only_deleter.cpp ;
427+
428+
run sp_is_bounded_array_test.cpp ;

test/sp_is_bounded_array_test.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2024 Peter Dimov
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
6+
#include <boost/core/lightweight_test_trait.hpp>
7+
8+
struct X;
9+
10+
int main()
11+
{
12+
using boost::detail::sp_is_bounded_array;
13+
14+
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<void> ));
15+
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<int> ));
16+
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<X> ));
17+
18+
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<int[]> ));
19+
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<X[]> ));
20+
21+
BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array<int[1]> ));
22+
BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array<int[7]> ));
23+
BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array<X[1]> ));
24+
BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array<X[7]> ));
25+
26+
return boost::report_errors();
27+
}

0 commit comments

Comments
 (0)