2
0
mirror of https://github.com/boostorg/parser.git synced 2026-01-19 04:22:13 +00:00

Fix transform_replace* in C++20 mode on GCC < 12.

This commit is contained in:
Zach Laine
2024-02-11 18:56:59 -06:00
parent 875eb9e4aa
commit 4287c9b7b3
5 changed files with 25 additions and 15 deletions

View File

@@ -3216,9 +3216,6 @@ overloads.
[important _trans_replace_ and _trans_replace_v_ are not available on MSVC in
C++17 mode.]
[important _trans_replace_ and _trans_replace_v_ are not available on GCC in
C++20 mode before GCC 12.]
_trans_replace_ creates _trans_replace_vs_. _trans_replace_v_ is a
`std::views`-style view. It produces a range of subranges from the parsed
range `r` and the given invocable `f`. Wherever in the parsed range a match

View File

@@ -131,7 +131,8 @@ namespace boost::parser::detail::text::detail {
constexpr all_impl all;
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS && \
(!defined(__GNUC__) || 12 <= __GNUC__)
template<typename R>
using all_t = std::views::all_t<R>;
#else

View File

@@ -44,13 +44,27 @@ namespace boost::parser::detail { namespace text {
using iterator_to_tag_t = decltype(iterator_to_tag<I>());
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
#if defined(__GNUC__) && __GNUC__ < 12
// This uses the final version of viewable_range. Older GCCs use a
// different one that breaks, so we use this on instead of the one
// from std::ranges::. It's missing the !initializer_list part.
template<typename T>
concept viewable_range = std::ranges::range<T> &&
((std::ranges::view<std::remove_cvref_t<T>> &&
std::constructible_from<std::remove_cvref_t<T>, T>) ||
(!std::ranges::view<std::remove_cvref_t<T>> &&
(std::is_lvalue_reference_v<T> ||
std::movable<std::remove_reference_t<T>>)));
#else
template<typename T>
concept viewable_range = std::ranges::viewable_range<T>;
#endif
template<class T>
using with_reference = T &;
template<typename T>
concept can_reference = requires { typename with_reference<T>; };
#endif
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
template<class Char>
struct cast_to_charn {
constexpr Char operator()(Char c) const { return c; }
@@ -265,7 +279,7 @@ namespace boost::parser::detail { namespace text {
#if BOOST_PARSER_DETAIL_TEXT_USE_ALIAS_CTAD
template<class R, auto F>
project_view(R &&) -> project_view<std::views::all_t<R>, F>;
project_view(R &&) -> project_view<detail::all_t<R>, F>;
#endif
namespace detail {
@@ -281,7 +295,7 @@ namespace boost::parser::detail { namespace text {
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
template<class R>
requires std::ranges::viewable_range<R> &&
requires viewable_range<R> &&
std::ranges::input_range<R> &&
std::regular_invocable<decltype(F)&, std::ranges::range_reference_t<R>> &&
detail::can_reference<std::invoke_result_t<decltype(F)&, std::ranges::range_reference_t<R>>>
@@ -402,7 +416,7 @@ namespace boost::parser::detail { namespace text {
{
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
template<class R>
requires (std::ranges::viewable_range<R> &&
requires (viewable_range<R> &&
std::ranges::input_range<R> &&
std::convertible_to<std::ranges::range_reference_t<R>, format_to_type_t<Format>>) ||
utf_pointer<std::remove_cvref_t<R>>
@@ -606,7 +620,7 @@ namespace boost::parser::detail { namespace text {
#if BOOST_PARSER_DETAIL_TEXT_USE_ALIAS_CTAD
template<format Format, class R>
utf_view(R &&) -> utf_view<Format, std::views::all_t<R>>;
utf_view(R &&) -> utf_view<Format, detail::all_t<R>>;
template<class V>
using utf8_view = utf_view<format::utf8, V>;
@@ -757,7 +771,7 @@ namespace boost::parser::detail { namespace text {
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
template<class R>
requires is_utf_view<std::remove_cvref_t<R>> ||
(std::ranges::viewable_range<R> &&
(viewable_range<R> &&
can_utf_view<unpacked_range<R>, View>) ||
utf_pointer<std::remove_cvref_t<R>>
#else

View File

@@ -3,8 +3,7 @@
#include <boost/parser/replace.hpp>
#if (!defined(_MSC_VER) || BOOST_PARSER_USE_CONCEPTS) && \
(!defined(__GNUC__) || 12 <= __GNUC__ || !BOOST_PARSER_USE_CONCEPTS)
#if (!defined(_MSC_VER) || BOOST_PARSER_USE_CONCEPTS)
namespace boost::parser {

View File

@@ -14,8 +14,7 @@
#include <list>
#if (!defined(_MSC_VER) || BOOST_PARSER_USE_CONCEPTS) && \
(!defined(__GNUC__) || 12 <= __GNUC__ || !BOOST_PARSER_USE_CONCEPTS)
#if (!defined(_MSC_VER) || BOOST_PARSER_USE_CONCEPTS)
namespace bp = boost::parser;