Skip to content

Commit

Permalink
Add the condition that BOOST_PARSER_USE_CONCEPTS is true to/in place …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
tzlaine committed Apr 1, 2024
1 parent a37a122 commit d774edc
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/boost/parser/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/parser/subrange.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/boost/parser/detail/printing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename Context, typename Parser>
void print_parser(
Context const & context,
Expand Down
2 changes: 1 addition & 1 deletion include/boost/parser/detail/printing_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename Context, typename Parser>
void print_parser(
Context const & context,
Expand Down
3 changes: 2 additions & 1 deletion include/boost/parser/detail/stl_interfaces/view_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions include/boost/parser/detail/text/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +36,7 @@ namespace boost::parser::detail { namespace text { namespace detail {
#include <boost/parser/detail/text/detail/begin_end.hpp>
#endif

#if defined(__cpp_lib_ranges)
#if BOOST_PARSER_USE_CONCEPTS
# define BOOST_PARSER_DETAIL_TEXT_SUBRANGE std::ranges::subrange
#else
# include <boost/parser/subrange.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/boost/parser/detail/text/transcode_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions include/boost/parser/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4600,7 +4600,7 @@ namespace boost { namespace parser {
Parser parser_;
};

#if defined(__cpp_lib_concepts)
#if BOOST_PARSER_USE_CONCEPTS
template<typename Parser>
struct string_view_parser
{
Expand Down Expand Up @@ -5989,7 +5989,7 @@ namespace boost { namespace parser {
`parser_interface<P>`. */
inline constexpr directive<raw_parser> 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<string_view_parser<P>>` from a given parser of type
`parser_interface<P>`. This is only available in C++20 and later. */
Expand Down
2 changes: 1 addition & 1 deletion include/boost/parser/parser_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace boost { namespace parser {
template<typename Parser>
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<char_type>` within a semantic action on
Expand Down
4 changes: 2 additions & 2 deletions test/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ int main()
}
}

#if defined(__cpp_lib_concepts)
#if BOOST_PARSER_USE_CONCEPTS
// string_view
{
{
Expand Down Expand Up @@ -2805,7 +2805,7 @@ int main()
}


#if defined(__cpp_lib_concepts)
#if BOOST_PARSER_USE_CONCEPTS
// string_view_doc_example
{
namespace bp = boost::parser;
Expand Down
6 changes: 4 additions & 2 deletions test/replace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
Expand Down
2 changes: 1 addition & 1 deletion test/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d774edc

Please sign in to comment.