diff --git a/include/boost/multi/detail/index_range.hpp b/include/boost/multi/detail/index_range.hpp index efc52c0f0..d94be6e82 100644 --- a/include/boost/multi/detail/index_range.hpp +++ b/include/boost/multi/detail/index_range.hpp @@ -178,7 +178,7 @@ class range { ++curr_; return *this; } - constexpr auto operator--() -> const_iterator& { + constexpr auto operator--() noexcept(noexcept(--curr_)) -> const_iterator& { --curr_; return *this; } diff --git a/test/layout.cpp b/test/layout.cpp index c88b8d0ad..ce1a36463 100644 --- a/test/layout.cpp +++ b/test/layout.cpp @@ -1275,6 +1275,34 @@ auto main() -> int { // NOLINT(readability-function-cognitive-complexity,bugpro BOOST_TEST( lyt.extension().front() == 3 ); BOOST_TEST( lyt.extension().back() == 8 ); } + { + multi::extension_t const ext(5); + + BOOST_TEST( *ext.begin() == 0 ); + BOOST_TEST( *(ext.end() - 1) == 4 ); + +#if !defined(__clang_major__) || (__clang_major__ != 15) +#if defined(__cpp_lib_ranges) && (__cpp_lib_ranges >= 201911L) && !defined(_MSC_VER) + BOOST_TEST( *std::ranges::begin(ext) == 0 ); + BOOST_TEST( *(std::ranges::end(ext)-1) == 4 ); + + BOOST_TEST( ext[0] == 0 ); + BOOST_TEST( ext[1] == 1 ); + BOOST_TEST( ext[4] == 4 ); + + static_assert(std::ranges::range>); + static_assert(std::ranges::range const>); + static_assert(std::ranges::range>>); + + // std::ranges::ref_view> + auto rext = ext | std::views::reverse; + + BOOST_TEST( rext[0] == 4 ); + BOOST_TEST( rext[1] == 3 ); + BOOST_TEST( rext[4] == 0 ); +#endif +#endif + } return boost::report_errors(); }