
On Thursday, February 09, 2012 15:33:03 Andrzej Krzemienski wrote:
I believe that optional<reference_wrapper<T>> would serve your purpose best. Or would it also introduce the lack of uniformity?
One additional note on this. I would like optional<T&> to be perfectly implementable as a wrapper around T*. optional<reference_wrapper<T>> does not allow this, at least not with its generic interface, since optional<T>::get() returns T&, which effectively forces optional<reference_wrapper<T>> to store reference_wrapper internally (along with the value presence flag). Specializing optional on std::reference_wrapper does not solve the problem entirely because there is also boost::reference_wrapper. It would be odd if optional worked differently with different reference_wrappers.