From 9d1a6aeeb31fb6ad33ec71eab40b5458b0553cce Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Sun, 28 Jan 2024 14:03:02 -0600 Subject: [PATCH] Extend all_t test to test arrays; fix errors. --- .../boost/parser/detail/text/detail/all_t.hpp | 4 +- include/boost/parser/parser.hpp | 2 +- test/all_t.cpp | 41 +++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/include/boost/parser/detail/text/detail/all_t.hpp b/include/boost/parser/detail/text/detail/all_t.hpp index c4c7cab0..6a977cb2 100644 --- a/include/boost/parser/detail/text/detail/all_t.hpp +++ b/include/boost/parser/detail/text/detail/all_t.hpp @@ -19,8 +19,8 @@ namespace boost::parser::detail::text::detail { template using iterator_ = decltype(text::detail::begin(std::declval())); - template - using sentinel_ = decltype(text::detail::end(std::declval())); + template + using sentinel_ = decltype(text::detail::end(std::declval())); template constexpr bool range_ = diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index fc48d783..b137f857 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -1009,7 +1009,7 @@ namespace boost { namespace parser { decltype(detail::text::detail::begin(std::declval())); template using sentinel_t = - decltype(detail::text::detail::end(std::declval())); + decltype(detail::text::detail::end(std::declval())); template using iter_value_t = typename std::iterator_traits::value_type; template diff --git a/test/all_t.cpp b/test/all_t.cpp index 98bf888d..956f69ac 100644 --- a/test/all_t.cpp +++ b/test/all_t.cpp @@ -61,3 +61,44 @@ TEST(all_t, basic) detail::all_t, detail::owning_view>); } + +TEST(all_t, array) +{ + char str[] = "text"; + char const const_str[] = "text"; + + static_assert(detail::range_); + static_assert(std::is_object_v); + detail::ref_view ref_view_(str); + { + auto && result = detail::all( + BOOST_PARSER_SUBRANGE(std::begin(const_str), std::end(const_str))); + static_assert(std::is_same_v< + decltype(result), + BOOST_PARSER_SUBRANGE &&>); + } + { + auto && result = detail::all(str); + static_assert( + std::is_same_v &&>); + } + { + auto && result = detail::all(const_str); + static_assert(std::is_same_v< + decltype(result), + detail::ref_view &&>); + } + + static_assert( + std::is_same_v< + detail::all_t>, + BOOST_PARSER_SUBRANGE>); + + static_assert( + std:: + is_same_v, detail::ref_view>); + + static_assert(std::is_same_v< + detail::all_t, + detail::ref_view>); +}