last day (15 days later) »
hoffmale
14:54
@Incomputable hi
Incomputable
the problem with behaving like an iterator lies in expensiveness of computing the distance, end iterator
@hoffmale, hi, thanks for joining
hoffmale
Well, that's always the problem with infinte ranges
they are infinite
Incomputable
it is unfortunate that standard library doesn't support sentinel values yet
hoffmale
Most range libraries (like the ranges v3 one) have some kind of limiter function, though
Incomputable
I thought about following the range interface, but creating something like a merger
hoffmale
14:57
e.g. only take up to n elements from the range
Incomputable
I think that it is important to separate check for past-the-end from iteration, thus something like
std::xxx_n
functions won't need to pay for the checks
@hoffmale I guess I should've read about them before writing the code
hoffmale
Eric Niebler did a talk some years ago about the ideas behind his ranges library
in there, he showed a calendar display using infinite ranges
Incomputable
@hoffmale I believe I watched it on cppcon, but it looked like a wall of code
hoffmale
yeah ^^ that one
Incomputable
the output looked nice though
I thought about adding ability to not advance the range with the value retrieval, but then I thought that ranges might get out of sync
which is probably not desired
hoffmale
15:03
"to not advance the range"
what do you mean by that?
Incomputable
oh, the current iterator
sorry, I've caught an illness, I might make mistakes from time to time
at least more often than usual :)
hoffmale
Oh, I get it
I was confused for a bit
Because ranges by themselves are just a pair of iterators, and the same two iterators can be requested as often as needed
hoffmale
15:33
@Incomputable just saw I forgot to put the usage example on godbolt
wandbox.org/permlink/a3cJxsKsonbdbEmF
Here's it in executable form
I commented those template restrictions, because MSVC wouldn't compile it otherwise <.<
Incomputable
@hoffmale thanks, that looks neat. I'll try to put more effort into encorporating existing iterator interface
IIRC latest VC++ should handle it
lemme check
it compiles well
try to update the VS, they push changes quite often
hoffmale
Hmm... looks like it didn't like the
value_type
type alias in the
std::is_constructible_v
part
replacing it with
typename std::iterator_traits<Iterator>::value_type
there fixed it
Incomputable
the code is certainly correct, so I guess it is just a problem with older VC++
I've got work to do, sorry, I'll come back when I'll have some ideas about improving the interface
hoffmale
Sure ^^
last day (15 days later) »
all rooms
Transcript for
Aug '18
21
Sep
5
discussion about endless stream
the room is about a post and accompanying answers,
codereview....
join this room
about this room
00:00
06:00
12:00
18:00
all times are UTC
site design / logo © 2025 Stack Exchange Inc;
legal
mobile