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

            Bug ID: 117094
           Summary: ranges::fill misses std::move for output_iterator
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

When sized_sentinel_for<_Sent, _Out> is true, ranges::fill dispatches
ranges::fill_n(__first, __len, __value) while __first is not guaranteed to be
copyable.

#include <iostream>
#include <ranges>
#include <algorithm>

struct O {
  using difference_type = std::ptrdiff_t;
  O() = default;
  O(O&&) = default;
  O& operator=(O&&) = default;
  O& operator*();
  O& operator++();
  O operator++(int);
  O& operator=(int);
};

int main() {
  std::ranges::fill(std::views::counted(O{}, 5), 42);
}

https://godbolt.org/z/fz16aKv9v

Reply via email to