id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 1841,Optional: C++0x features,jgottman@…,akrzemi1,"There are a couple of features in C++0x that would be very useful in the optional library. First is the emplace function (see [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2345.pdf]). This is how the C++0x containers will do in-place construction; optional should allow it as well so the same operation can be done in the same way. One issue is what to do if we call emplace on an optional that is not empty. We could assert, throw an exception, reset and then construct in-place, or construct out-of-place and then swap. Personally I prefer the third option. Second, optional should make use of rvalue-references where available. Note that if swap() were implemented using the move constructor and move assignment operator, then it would just do the right thing with respect to iterators to the standard containers. {{{ template inline void optional_swap ( optional& x, optional& y ) { if ( !x && !!y ) { x.reset(std::move(*y)); y.reset(); } else if ( !!x && !y ) { y.reset(std::move(*x)); x.reset(); } else if ( !!x && !!y ) { // GCC > 3.2 and all other compilers have the using declaration at function scope (FLC) #ifndef BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE // allow for Koenig lookup using std::swap ; #endif swap(*x,*y); } } }}} ",Patches,closed,Boost 1.56.0,optional,Boost 1.36.0,Problem,fixed,,