[Bug libstdc++/100833] New: ranges::advance should return n when i == bound
hewillk at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun May 30 13:51:42 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100833
Bug ID: 100833
Summary: ranges::advance should return n when i == bound
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: ---
This is specified in [range.iter.op.advance#7]:
"Returns: n - M, where M is the difference between the ending and starting
positions of i."
#include <ranges>
constexpr auto diff = [] {
auto r = std::views::single(0) |
std::views::filter([](int) { return true; });
auto it = r.begin();
return std::ranges::advance(it, 100, r.begin());
}();
static_assert(diff == 100);
https://godbolt.org/z/6nh8xMWYd
More information about the Gcc-bugs
mailing list