Page MenuHomePhabricator

Implement the non-parallel versions of exclusive_scan and transform_exclusive_scan
ClosedPublic

Authored by mclow.lists on Jun 8 2017, 9:16 AM.

Details

Summary

These are part of C++17. Later, we'll get the parallel versions.

Diff Detail

Event Timeline

mclow.lists created this revision.Jun 8 2017, 9:16 AM
wash added inline comments.Jun 8 2017, 4:02 PM
include/numeric
182

If __first == __last, this initialization is unnecessary; I'd refactor this so that we check for __first != __last first.

208

If __first == __last, this initialization is unnecessary; I'd refactor this so that we check for __first != __last first.

wash edited edge metadata.EditedJun 8 2017, 4:29 PM

https://gist.github.com/brycelelbach/137f1e45b737d615134e228ec0c84f3a <- some crude tests I wrote based on slides/notes of mine.

EDIT: Okay, looks good, your implementation passes my little tests.

wash added a comment.EditedJun 8 2017, 4:53 PM

This implementation works, but performs unnecessary operations.

https://gist.github.com/brycelelbach/907ac3b8a74603cc189897ab789a65a9

The "next" result is calculated in each iteration; this means one unnecessary application of the binary op (the "next" result on the final iteration).

EDIT: I don't think we can avoid this for the case of InputIterators (and ForwardIterators?), because we can't decrement last.

Added a _VSTD::, made some assertions static_assert, and addressed Bryce's concerns about doing an init when the input range is empty.

mclow.lists marked 2 inline comments as done.Jun 8 2017, 8:02 PM

Turn the for loops into do-while loops, saving a comparison.

Add extra tests to make sure that the calculations are not done using the source sequence value_type.

Previous update was br0ken. This is better. :-)
Add a test to ensure that the calculations are done using the correct type.

The init typedef test looks good to me.

This all looks good to go.

mclow.lists accepted this revision.Jun 13 2017, 7:24 AM

This was committed as r305136

This revision is now accepted and ready to land.Jun 13 2017, 7:24 AM
mclow.lists closed this revision.Jun 13 2017, 7:24 AM