https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93936

            Bug ID: 93936
           Summary: [ranges]
                    std::ranges::split_view<...>::_OuterIter<...>::__curre
                    nt() is private within this context
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

The following program fails to compile with -std=c++2a on gcc-trunk:

#include <ranges>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

inline constexpr auto as_string = [](std::ranges::view auto rng) {
    auto in = rng | std::views::common;
    return std::string(in.begin(), in.end());
};

int main() {
    namespace views = std::views;
    std::string str = "Now is the time for all good men to come to the aid of
their county.";
    auto rng = str | views::split(' ') | views::transform(as_string) |
views::common;
    std::vector<std::string> words(rng.begin(), rng.end());
    std::ranges::copy(words,
std::ostream_iterator<std::string>{std::cout,","});
}

The error is:

/opt/compiler-explorer/gcc-trunk-20200225/include/c++/10.0.1/ranges:2828:31:
error: 'constexpr auto& std::ranges::split_view<_Vp,
_Pattern>::_OuterIter<_Const>::__current() const [with bool _Const = true; _Vp
= std::ranges::ref_view<std::__cxx11::basic_string<char> >; _Pattern =
std::ranges::single_view<char>]' is private within this context

 2828 |    { return __x._M_i.__current() == __y._M_i.__current(); }

      |             ~~~~~~~~~~~~~~~~~~^~

Obligatory godbolt link: https://godbolt.org/z/B4tZPx

Reply via email to