conditionally enabling constructor

Posted by MK on Stack Overflow See other posts from Stack Overflow or by MK
Published on 2011-03-20T00:01:32Z Indexed on 2011/03/20 0:10 UTC
Read the original article Hit count: 176

Filed under:
|
|

Here is how I can conditionally enable a constructor of a class :

struct Foo
{

    template<class T>
    Foo( T* ptr, boost::enable_if<is_arithmetic<T> >::type* = NULL )
    {}

};

I would like to know why I need to do the enabling via a dummy parameter. Why can I not just write :

struct Foo
{
    template<class T>
    Foo( boost::enable_if<is_arithmetic<T>, T>::type* = NULL )
    {}
};

© Stack Overflow or respective owner

Related posts about c++

Related posts about constructor