config.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (C) 2020 T. Zachary Laine
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_PARSER_DETAIL_TEXT_CONFIG_HPP
  7. #define BOOST_PARSER_DETAIL_TEXT_CONFIG_HPP
  8. #include <boost/parser/config.hpp>
  9. // Included for definition of __cpp_lib_concepts.
  10. #include <iterator>
  11. #if !BOOST_PARSER_USE_CONCEPTS
  12. # define BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS 0
  13. #else
  14. # define BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS 1
  15. #endif
  16. #if BOOST_PARSER_USE_CONCEPTS
  17. namespace boost::parser::detail { namespace text { namespace detail {
  18. inline constexpr auto begin = std::ranges::begin;
  19. inline constexpr auto end = std::ranges::end;
  20. }}}
  21. #else
  22. #include <boost/parser/detail/text/detail/begin_end.hpp>
  23. #endif
  24. #if BOOST_PARSER_USE_CONCEPTS
  25. # define BOOST_PARSER_DETAIL_TEXT_SUBRANGE std::ranges::subrange
  26. #else
  27. # include <boost/parser/subrange.hpp>
  28. # define BOOST_PARSER_DETAIL_TEXT_SUBRANGE boost::parser::subrange
  29. #endif
  30. namespace boost::parser::detail { namespace text {
  31. #if defined(__cpp_char8_t)
  32. using char8_type = char8_t;
  33. #else
  34. using char8_type = char;
  35. #endif
  36. }}
  37. // The inline namespaces v1 and v2 represent pre- and post-C++20. v1 is
  38. // inline for standards before C++20, and v2 is inline for C++20 and later.
  39. // Note that this only applies to code for which a v2 namespace alternative
  40. // exists. Some instances of the v1 namespace may still be inline, if there
  41. // is no v2 version of its contents.
  42. #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
  43. # define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 namespace v1
  44. # define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 inline namespace v2
  45. #else
  46. # define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 inline namespace v1
  47. # define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 namespace v2
  48. #endif
  49. #endif