Add array_elems_test.cpp

This commit is contained in:
Peter Dimov
2025-01-10 02:57:33 +02:00
parent f9bb980a0b
commit e0bd7e8560
2 changed files with 27 additions and 0 deletions

View File

@ -29,6 +29,7 @@ run array_hash.cpp
#
run array_typedef_test.cpp ;
run array_elems_test.cpp ;
#

26
test/array_elems_test.cpp Normal file
View File

@ -0,0 +1,26 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T, std::size_t N> void test()
{
boost::array<T, N> a = {};
T (&e)[ N ] = a.elems;
BOOST_TEST_EQ( static_cast<void const*>( e ), static_cast<void const*>( &a ) );
}
int main()
{
test<int, 1>();
test<int, 7>();
test<int const, 1>();
test<int const, 7>();
return boost::report_errors();
}