
I'm normally against obscure functions that are meant to save a few keystrokes. OTOH, while the verbose alternative is perfectly clear and I wouldn't even consider searching for a shortcut, this particular shortcut looks clear enough to justify it.
So, Arno: don't you agree swap is better?
Would a function like optional<T>::swap_if_initialized(T&) indeed be the preferable one for Arno's use case? It isn't yet entirely clear to me, as it seems that Arno would like to have an implicit conversion, while passing the value from optional<T> to its target.
Sorry for not responding earlier. I don't see how my use case is special over regular assignment, apart from the fact that the assignment is conditional. Like for any assignment, move optimization is certainly appreciated, and my use cases are indeed r-value assignments. 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