Skip to content

Conversation

@Quuxplusone
Copy link
Contributor

T old = m_copy;
using std::swap;
swap(old, t);
return old;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dance makes the operation exception-safe, in case that matters. If copying m_copy into old throws an exception, then the swap doesn't happen and the value of t is preserved.

copy_popper(T&& t);
T operator()(T& t);
T copy;
explicit copy_popper(T t);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that I'm changing this from T&& to just T, which fixes #102 in an elegant way. I don't think there's any downside to this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explicit broke one of the tests included here: aba9766#commitcomment-22430301

@hatcat hatcat merged commit d6ad218 into WG21-SG14:master Jun 6, 2017
@Quuxplusone Quuxplusone deleted the ajo-poppers branch July 2, 2018 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add missing copy_popper(T const&) ctor for ring_span Fix return of ring_span's copy_popper<T>::operator()

3 participants