Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2003-02-24 18:46:07


Fernando Cacciola wrote:

[...]

>> 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.

... but the number of arguments is limited this way.

Philippe A. Bouchard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk