Boost logo

Boost :

From: Simon Buchan (simon_at_[hidden])
Date: 2005-09-26 21:47:19


Jason Hise wrote:
> Simon Buchan wrote:
>
>
>>[...]
>>
>>*shrug*, I guess. I probably don't quite understand what he's trying to do.
>>
>>
>
> I am trying to provide a create member function of singleton_ptr which
> forwards any parameters passed to it to the singleton's constructor.

Hmm, that is tricky. Do you really think you could PP generate the
overloads? (I haven't seen it in the Boost functional headers, but I
didn't get too deep in them)
The boost headers just use P1& (they call it A1) directly, but you could
try something like:

template <class P1>
void create( P1 & p1 )
{ do_create<call_traits<P1>::param_type>(p1);
}

template <class P1>
void create( P1 const & p1 ) // for rval arguments
{ do_create<call_traits<P1>::param_type>(p1);
}

template <class P1>
void do_create( P1 p1 )
{
}

(Disclaimer: not tested)
Of course, this means for 9 arguments, you have 512 overloads to write,
and that's not counting the extra do_create overloads! (Is this where PP
magic could help?)


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