Quantcast
Channel: User HolyBlackCat - Stack Overflow
Viewing all articles
Browse latest Browse all 1262

Answer by HolyBlackCat for `std::iota_view` is slow when given different types of value and bound?

$
0
0

When iota_view receives different argument types, .end() returns a sentinel instead of an iterator.

A sentinel is a type that's ==-comparable with an iterator, and optionally subtractible from it (the latter makes it a sized sentinel).

If it happens to not be subtractible, ranges::partition_point can't know the range size in advance, and has to increment the iterator step by step (almost as if it wasn't random-access).

For some reason, for iota_view<A,B> this sentinel is specified to overload - only if std::sized_sentinel_for<B, A> == true, which is false, because neither is an iterator in this case (int and long long).


Viewing all articles
Browse latest Browse all 1262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>