Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-03-16 06:18:50


On Sat, 15 Mar 2003 13:15:59 -0600, "David B. Held"
<dheld_at_[hidden]> wrote:

>"Daniel Frey" <daniel.frey_at_[hidden]> wrote in message
>news:3E7368DB.69A4FDC7_at_aixigo.de...
>> [...]
>> The compiler has no idea how to deduce U as - depending on
>> U - param_type could change.
>> [...]
>
>Oh, yes, I see. I guess call_traits is only useful when T is a
>class template parameter. A bit unfortunate, isn't it? I mean, it
>isn't very useful for function forwarding then, is it?

I don't know if it's useful or not but it's certainly usable. The fact
that deduction fails in your case doesn't mean it fails always; and
for named templates there's still the possibility to explicit specify
template arguments. In your case, you could do:

class foo
{
public:
    template <typename U>
    foo(typename boost::call_traits<U>::param_type v, U*)
    { }

};

int main()
{
    X x;
    foo f(x, (X*)0 );
    ...
}

It's a hack, of course, but you can always see "(X*)0" as a
syntactical alternative to "<X>" :-)

Genny.


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