jeudi 29 décembre 2016

Template specialisation with enable_if and is_arithmetic for a class

I am trying to implement a Expression class with 2 specialisation for arithmetic types. This is the default class:

    template<typename Left, typename Op, typename Right, typename std::enable_if<!std::is_arithmetic<Left>::value, Left>::type* = nullptr>
class Expression { ... }

And those are the two specialisations:

    template<typename Left, typename Op, typename Right, typename std::enable_if<std::is_arithmetic<Left>::value, Left>::type* = nullptr>
class Expression { ... }

    template<typename Left, typename Op, typename Right, typename std::enable_if<std::is_arithmetic<Right>::value, Right>::type* = nullptr>
class Expression { ... }

If I now compile my code I get this error:

Error C3855 'Expression': template parameter '__formal' is incompatible with the declaration Vector

How can I solve my problem with templates and specialisation or dummy types as I used them.

Aucun commentaire:

Enregistrer un commentaire