"Philippe A. Bouchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Fernando Cacciola (Home) wrote: > > [...] > > > I'm still not sure I understand what are you trying to do, but it > > looks > > like you want optional with in-place construction (which bypasses the > > copy). In this case, I recently explored something which would look > > like: > > > > optional<Window> opt( in_place<Window>(point(0,0),point(10,10))); > > > > here, in_place() is used to forward T's ctor argument to optional<> > > so that > > T is effectively constructed in-place right within the aligned > > storage. > > > > Is this what you want? > > Yes, something like that. I am curious to know how in_place<> works. > Look at the thread "'optional' - request for extension" Essentilly,
in_place<T>(a0,a1,a2...) just creates a function object which holds onto the argument list: template<class T, class A0, class A1> struct in_place_factory2 { in_place_factory2( A0& a0, A1& a2) : m_a0(a0), m_a1(a1) {} A0& m_a0 ; A1& m_a1 ; } and which has the following function call operator: void operator() ( void* address ) const { new (address) T(m_a0,m_a1); } optional<> ctor just calls the function object passing its own m_storage as a parameter. -- Fernando Cacciola _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost