dimanche 27 septembre 2015

C++11 Template conditional

I want to write template with conditional for only numbers.

//in header file
template <typename T,
    typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type 
>
class Foo
{
    public:
        Foo();
};

#include "Foo.inline"

And

//In inline file
template <
    typename T
>
Foo<T>::Foo()
{
};

However, this does not compile. How should be the syntax to have template implementation in separate file?

Aucun commentaire:

Enregistrer un commentaire