|
Boost : |
Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-02-09 12:54:42
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk