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

            Bug ID: 113055
           Summary: possibly-const-range missing constraints
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

ranges_base.h#L628:

    template<typename _Range>
      constexpr auto&
      __possibly_const_range(_Range& __r) noexcept
      {
        if constexpr (constant_range<const _Range> && !constant_range<_Range>)
          return const_cast<const _Range&>(__r);
        else
          return __r;
      }

But according to the current wording, _Range must satisfy input_range, which
means the following should not be accepted:

  #include <ranges>
  #include <vector>

  int main() {
    std::vector<int> v;
    auto r = std::views::counted(std::back_inserter(v), 3);
    auto ce = std::ranges::cend(r);
  }

https://godbolt.org/z/Wa4Y3fPa6

Although I tried to submit LWG 3768, but it was rejected.

Reply via email to