a88fc03ba7
The assertion in the subrange constructor causes semantic changes, because the call to ranges::distance performs additional operations that are not part of the constructor's specification. That will fail to compile if the iterator is move-only, because the argument to ranges::distance is passed by value. It will modify the subrange if the iterator is not a forward iterator, because incrementing the copy also affects the _M_begin member. Those problems could be prevented by using if-constexpr to only do the assertion for copyable forward iterators, but the call to ranges::distance can also prevent the constructor being usable in constant expressions. If the member initializers are usable in constant expressions, but iterator increments of equality comparisons are not, then the checks done by __glibcxx_assert might make constant evaluation fail. This change removes the assertion. Additionally, a new typedef is introduced to simplify the declarations using __make_unsigned_like_t on the iterator's difference type. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/ranges_util.h (subrange): Add __size_type typedef and use it to simplify declarations. (subrange(i, s, n)): Remove assertion. * testsuite/std/ranges/subrange/constexpr.cc: New test. |
||
---|---|---|
.. | ||
backward | ||
bits | ||
c | ||
c_compatibility | ||
c_global | ||
c_std | ||
debug | ||
decimal | ||
experimental | ||
ext | ||
parallel | ||
precompiled | ||
pstl | ||
std | ||
tr1 | ||
tr2 | ||
Makefile.am | ||
Makefile.in |