r/cpp • u/_VZ_ wx | soci | swig • Jun 17 '15
Standardizing Variant: Difficult Decisions
https://www.justsoftwaresolutions.co.uk/cplusplus/standardizing-variant.html
31
Upvotes
r/cpp • u/_VZ_ wx | soci | swig • Jun 17 '15
View all comments
Show parent comment
3
u/sellibitze Jun 18 '15
IIRC one of the motivations to allow throwing move ctors was
std::pair<some_legacy_type, some_move_optimized_type>wheresome_legacy_typeonly has a possibly throwing copy ctor andsome_move_optimized_typecomes with a non-throwing move ctor. So, you end up with a possibly throwing move ctor for thispair. But it will be preferable to its copy ctor in the situations where you don't need a move to have the strong exception guarantee.But yeah, throwing move ctors are making things complicated. In other languages like D and Rust, the move semantics story is much simpler (and a teensy bit less powerful but that's IMHO ok).