Boost logo

Boost :

From: Ross Smith (r-smith_at_[hidden])
Date: 2001-10-26 07:50:24


Peter Dimov wrote:
>
> All these solutions have a common drawback:
>
> template<class Numeric> void foo(Numeric n);
>
> foo(pi()); // calls void foo<some_type_that_is_not_numeric>

foo(double(pi()));

Actually I think that specific example falls foul of the infamous
is-it-a-function-call-or-a-declaration bug^H^H^Hfeature of the language
and would have to be written as a static_cast rather than a
constructor-style cast. But you get the idea.

_Any_ generic solution would require the type to be explicitly specified
in this sort of context; mine is no worse than anyone else's.

-- 
Ross Smith ...................................... Auckland, New Zealand
r-smith_at_[hidden] ........................ http;//halflife.mani.ac.nz/
        "A wise man learns from the mistakes of others; a fool
        learns only from his own."     -- Gen. Aleksandr Lebed

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