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
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:8ce13842b50cbd2676f2e322995182af20df31fe commit r10-6871-g8ce13842b50cbd2676f2e322995182af20df31fe Author: Patrick Palka <ppalka@redhat.com> Date: Wed Feb 26 08:38:06 2020 -0500 libstdc++: Fix use of inaccessible private member in split_view (PR93936) We are calling _OuterIter::__current from _InnerIter::operator==, but the former is private within this non-member friend. Fix this by calling _OuterIter::operator== instead, which does the right thing here. libstdc++-v3/ChangeLog: PR libstdc++/93936 * include/std/ranges (split_view::_InnerIter::operator==): Compare the operands' _M_i rather than their _M_i.current(). * testsuite/std/ranges/adaptors/split.cc: Augment test.
This should be fixed now.