jeudi 19 avril 2018

Definition of C++ template specialization member function

Given the following class and specializations. How would I implement the function bodies for the template class and both specializations outside of the class definition? Obviously, each function implementation would need to be declared inline.

template <typename T1, typename = void>
struct MyClass
{
    void func();
};
template <typename T1>
struct MyClass<T1, std::enable_if_t<std::is_integral<T1>::value>>
{
    void func();
};
template <typename T1>
struct MyClass<T1, std::enable_if_t<std::is_floating_point<T1>::value>>
{
    void func();
};

Aucun commentaire:

Enregistrer un commentaire