
Thus, until move semantics are practically usable (whether via Boost.Move or C++0x) I would either add the three functions as member functions, or just your optional_assign() as a free function, but not two members and one free standing.
What do you think?
FWIW, my vote would go to your first option, adding optional_assign_to(T&), optional_move_to(T&), and optional_swap(T&) as member functions to optional<T>. But of course, my name isn't Arno!
I am happy with members. Just for my understanding, why are optional_swap and optional_move_to not expessible as free functions? template< class T, class U > bool optional_move( T& t, boost::optional<U>& u ) { if( u ) { t=*u; return true; } else { return false; } }; template< class T > bool optional_move( T& t, boost::optional<T>& u ) { if( u ) { swap( t, *u ); return true; } else { return false; } }; { int i; boost::optional<int> j=1; optional_move( i, j ); // swaps } { double i; boost::optional<int> j=1; optional_move( i, j ); // assigns with implicit conversion } What am I missing? Arno -- Dr. Arno Schoedl · aschoedl@think-cell.com Technical Director think-cell Software GmbH · Invalidenstr. 34 · 10115 Berlin, Germany http://www.think-cell.com · phone +49-30-666473-10 · toll-free (US) +1-800-891-8091 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht Charlottenburg, HRB 85229