Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2003-05-12 08:31:18


On Monday, May 12, 2003, at 04:59 AM, Hubert Holin wrote:

> I welcome any suggestion on that matter (and would most welcome
> somebody showing me what I got wrong :-) ).

To be honest I haven't tried it with template template overloads. But
it looks like you're looking for restricted templates for 1 and 2
(especially 1). Search the newsgroups for "restrict_to" and
"enable_if" and/or see the June '03 CUJ feature article.

-Howard

template <bool b, class T = void> struct restrict_to {};
template <class T> struct restrict_to<true, T> {typedef
T type;};

template<typename T>
typename restrict_to
<
     is_floating<T>::value,
     T
>::type
f(T x)
{
    ::std::cout << "Plain vanilla templated function (for floating point
types only)" << ::std::endl;

    return(x);
}


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