News for hackers. Stuff that matters.
Re:C++14: Transducers by gue5t on Wednesday December 16, 2015 @06:40PM (#10748287)
Can you describe some situations in which this problem comes up? I'm having a hard time imagining when I would want/expect an iterator adaptor that does something useful on an empty/finished input.
Re:C++14: Transducers by kybernetikos on Wednesday December 16, 2015 @06:51PM (#10748373)
It's not so much empty/finished, it's that values are produced at particular times, perhaps as the user clicks the mouse, or as messages come in from the network or over stdin.

Maybe you're writing some web page analytics software. Let's say you've got a stream of values representing the (x,y) positions of mouse clicks, you want to filter out any that are more than a predefined distance from a particular point, then remove any that occur 200ms or less than the last one, then every time you have 10 of them you want to post them to the server. How would you do this with iterator adaptors?

With transducers, the exact same filter that removes points further than a particular distance away in the event stream can be used on any source (e.g. an iterator).