From 2099995189400d0bff0cb971d234a5a6d9e3e014 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Nov 2024 03:56:02 +0200 Subject: [PATCH] Uncomment BOOST_CONSTEXPR; update and enable test/array_constexpr.cpp --- include/boost/array.hpp | 8 ++++---- test/Jamfile.v2 | 2 +- test/array_constexpr.cpp | 18 ++++-------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 02bd76d..21e6632 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -117,14 +117,14 @@ namespace boost { return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } - /*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const + BOOST_CONSTEXPR const_reference operator[](size_type i) const { return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } // at() with range check reference at(size_type i) { return rangecheck(i), elems[i]; } - /*BOOST_CONSTEXPR*/ const_reference at(size_type i) const { return rangecheck(i), elems[i]; } + BOOST_CONSTEXPR const_reference at(size_type i) const { return rangecheck(i), elems[i]; } // front() and back() reference front() @@ -246,14 +246,14 @@ namespace boost { return failed_rangecheck(); } - /*BOOST_CONSTEXPR*/ const_reference operator[](size_type /*i*/) const + BOOST_CONSTEXPR const_reference operator[](size_type /*i*/) const { return failed_rangecheck(); } // at() with range check reference at(size_type /*i*/) { return failed_rangecheck(); } - /*BOOST_CONSTEXPR*/ const_reference at(size_type /*i*/) const { return failed_rangecheck(); } + BOOST_CONSTEXPR const_reference at(size_type /*i*/) const { return failed_rangecheck(); } // front() and back() reference front() diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ef83df7..19f857e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,7 +18,7 @@ run array5.cpp ; run array6.cpp ; run array7.cpp ; -# run array_constexpr.cpp ; +compile array_constexpr.cpp ; compile-fail array_getfail1.cpp ; compile-fail array_getfail2.cpp ; diff --git a/test/array_constexpr.cpp b/test/array_constexpr.cpp index 48995c9..a6c0dc6 100644 --- a/test/array_constexpr.cpp +++ b/test/array_constexpr.cpp @@ -5,27 +5,15 @@ * http://www.boost.org/LICENSE_1_0.txt) */ -#include -#include #include -#include -#ifndef BOOST_NO_CXX11_HDR_ARRAY -#include -#endif +#include #ifndef BOOST_NO_CXX11_CONSTEXPR + constexpr boost::array arr {{ 0,1,2,3,4,5,6,7,8,9 }}; -constexpr std::array arr_std {{ 0,1,2,3,4,5,6,7,8,9 }}; - -template -void sink ( T t ) {} - -template -void sink ( boost::array &arr ) {} int main() { -// constexpr int two = arr_std.at (2); constexpr int three = arr.at (3); int whatever [ arr.at(4) ]; (void)three; @@ -33,7 +21,9 @@ int main() } #else // no constexpr means no constexpr tests! + int main() { } + #endif