David Abrahams wrote:
[...]
>> 2) Placement operator new (size_t, boost::optional<T> &) definition
>> which I highly suggest.
>
> Your response is a bit too terse for me to understand. Care to
> clarify a bit?
Maybe the following placement operator new can help prevent copy constructor
usages:
#include <new>
template <typename T>
class optional
{
friend void * operator new (size_t, optional<T> &);
...
};
template <typename T>
inline void * operator new (size_t a_s, boost::optional<T> & a_o)
{
a_o.m_initialized = true;
return operator new (a_s, a_o.get());
}
Example:
optional<int> i;
new (i) int(17);
Philippe A. Bouchard
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost