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

            Bug ID: 100795
           Summary: ranges::sample should not use std::sample directly
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

Since some random access ranges are only input ranges in C++17, this will cause
ranges::sample to incorrectly reject the following valid case:


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

int main() {
  std::ranges::sample(
    std::views::iota(0, 42),
    std::ostream_iterator<int>{std::cout, " "},
    42,
    std::mt19937{std::random_device{}()});
}

https://godbolt.org/z/dbWWTPKhx

Reply via email to