From d774edc0e638a4e5bdfb5d4f22f8a01a6f6f7983 Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Sat, 30 Mar 2024 22:02:55 -0500 Subject: [PATCH] Add the condition that BOOST_PARSER_USE_CONCEPTS is true to/in place of many places that used __cpp_lib{concepts,ranges} previously. This is often necessary when concepts are disabled, since the user might have a broken implementation of concepts. --- include/boost/parser/config.hpp | 2 +- include/boost/parser/detail/printing.hpp | 2 +- include/boost/parser/detail/printing_impl.hpp | 2 +- include/boost/parser/detail/stl_interfaces/view_adaptor.hpp | 3 ++- include/boost/parser/detail/text/config.hpp | 4 ++-- include/boost/parser/detail/text/transcode_view.hpp | 2 +- include/boost/parser/parser.hpp | 4 ++-- include/boost/parser/parser_fwd.hpp | 2 +- test/parser.cpp | 4 ++-- test/replace.cpp | 6 ++++-- test/tracing.cpp | 2 +- 11 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/boost/parser/config.hpp b/include/boost/parser/config.hpp index e4f3931c..e78bb76b 100644 --- a/include/boost/parser/config.hpp +++ b/include/boost/parser/config.hpp @@ -86,7 +86,7 @@ # define BOOST_PARSER_USE_CONCEPTS 0 #endif -#if defined(__cpp_lib_ranges) +#if defined(__cpp_lib_ranges) && BOOST_PARSER_USE_CONCEPTS # define BOOST_PARSER_SUBRANGE std::ranges::subrange #else # include diff --git a/include/boost/parser/detail/printing.hpp b/include/boost/parser/detail/printing.hpp index 86805c30..1143832a 100644 --- a/include/boost/parser/detail/printing.hpp +++ b/include/boost/parser/detail/printing.hpp @@ -120,7 +120,7 @@ namespace boost { namespace parser { namespace detail { std::ostream & os, int components = 0); -#if defined(BOOST_PARSER_DOXYGEN) || defined(__cpp_lib_concepts) +#if defined(BOOST_PARSER_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template void print_parser( Context const & context, diff --git a/include/boost/parser/detail/printing_impl.hpp b/include/boost/parser/detail/printing_impl.hpp index 65596aa8..37f780c5 100644 --- a/include/boost/parser/detail/printing_impl.hpp +++ b/include/boost/parser/detail/printing_impl.hpp @@ -323,7 +323,7 @@ namespace boost { namespace parser { namespace detail { detail::print_directive(context, "raw", parser.parser_, os, components); } -#if defined(BOOST_PARSER_DOXYGEN) || defined(__cpp_lib_concepts) +#if defined(BOOST_PARSER_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS template void print_parser( Context const & context, diff --git a/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp b/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp index b4ea8368..b4a2af22 100644 --- a/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp +++ b/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp @@ -17,7 +17,8 @@ #if !defined(BOOST_STL_INTERFACES_DOXYGEN) -#if defined(__cpp_lib_ranges) && 202202L <= __cpp_lib_ranges +#if BOOST_PARSER_USE_CONCEPTS && defined(__cpp_lib_ranges) && \ + 202202L <= __cpp_lib_ranges #define BOOST_PARSER_USE_CPP23_STD_RANGE_ADAPTOR_CLOSURE 1 #else #define BOOST_PARSER_USE_CPP23_STD_RANGE_ADAPTOR_CLOSURE 0 diff --git a/include/boost/parser/detail/text/config.hpp b/include/boost/parser/detail/text/config.hpp index cb5043fc..ec353047 100644 --- a/include/boost/parser/detail/text/config.hpp +++ b/include/boost/parser/detail/text/config.hpp @@ -27,7 +27,7 @@ #define BOOST_PARSER_DETAIL_TEXT_USE_ALIAS_CTAD 0 #endif -#if defined(__cpp_lib_ranges) +#if BOOST_PARSER_USE_CONCEPTS namespace boost::parser::detail { namespace text { namespace detail { inline constexpr auto begin = std::ranges::begin; inline constexpr auto end = std::ranges::end; @@ -36,7 +36,7 @@ namespace boost::parser::detail { namespace text { namespace detail { #include #endif -#if defined(__cpp_lib_ranges) +#if BOOST_PARSER_USE_CONCEPTS # define BOOST_PARSER_DETAIL_TEXT_SUBRANGE std::ranges::subrange #else # include diff --git a/include/boost/parser/detail/text/transcode_view.hpp b/include/boost/parser/detail/text/transcode_view.hpp index 8eaedab2..e6e34901 100644 --- a/include/boost/parser/detail/text/transcode_view.hpp +++ b/include/boost/parser/detail/text/transcode_view.hpp @@ -801,7 +801,7 @@ namespace boost::parser::detail { namespace text { }} -#if defined(__cpp_lib_ranges) +#if BOOST_PARSER_USE_CONCEPTS && defined(__cpp_lib_ranges) namespace std::ranges { #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 0f3c67b6..0a117bd8 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -4600,7 +4600,7 @@ namespace boost { namespace parser { Parser parser_; }; -#if defined(__cpp_lib_concepts) +#if BOOST_PARSER_USE_CONCEPTS template struct string_view_parser { @@ -5989,7 +5989,7 @@ namespace boost { namespace parser { `parser_interface

`. */ inline constexpr directive raw; -#if defined(BOOST_PARSER_DOXYGEN) || defined(__cpp_lib_concepts) +#if defined(BOOST_PARSER_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS /** The `string_view` directive, whose `operator[]` returns a `parser_interface>` from a given parser of type `parser_interface

`. This is only available in C++20 and later. */ diff --git a/include/boost/parser/parser_fwd.hpp b/include/boost/parser/parser_fwd.hpp index b33b0c0a..7e7d95ca 100644 --- a/include/boost/parser/parser_fwd.hpp +++ b/include/boost/parser/parser_fwd.hpp @@ -221,7 +221,7 @@ namespace boost { namespace parser { template struct raw_parser; -#if defined(BOOST_PARSER_DOXYGEN) || defined(__cpp_lib_concepts) +#if defined(BOOST_PARSER_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS /** Applies the given parser `p` of type `Parser`. Regardless of the attribute produced by `Parser`, this parser's attribute is equivalent to `std::basic_string_view` within a semantic action on diff --git a/test/parser.cpp b/test/parser.cpp index 5a736a82..6450e7d4 100644 --- a/test/parser.cpp +++ b/test/parser.cpp @@ -1219,7 +1219,7 @@ int main() } } -#if defined(__cpp_lib_concepts) +#if BOOST_PARSER_USE_CONCEPTS // string_view { { @@ -2805,7 +2805,7 @@ int main() } -#if defined(__cpp_lib_concepts) +#if BOOST_PARSER_USE_CONCEPTS // string_view_doc_example { namespace bp = boost::parser; diff --git a/test/replace.cpp b/test/replace.cpp index 6c67284f..32d8ec98 100644 --- a/test/replace.cpp +++ b/test/replace.cpp @@ -34,8 +34,10 @@ namespace deduction { } #endif -// MSVC produces hard errors here, so ill_formed does not work. -#if defined(__cpp_char8_t) && !defined(_MSC_VER) +// MSVC and older Clangs produce hard errors here, so ill_formed does not +// work. +#if defined(__cpp_char8_t) && !defined(_MSC_VER) && \ + (!defined(__clang__) || 16 <= __clang__) char const empty_str[] = ""; template diff --git a/test/tracing.cpp b/test/tracing.cpp index de9cd6d5..1d94fb53 100644 --- a/test/tracing.cpp +++ b/test/tracing.cpp @@ -171,7 +171,7 @@ int main() PARSE(raw[char_]); -#if defined(__cpp_lib_concepts) +#if BOOST_PARSER_USE_CONCEPTS std::cout << "\n\n" << "----------------------------------------\n" << "| string_view[] |\n"