mercredi 2 mars 2016

CRTP compiling error

The following will compile with GCC 5.2 but not with Visual Studio 2015.

template <typename Derived>
struct CRTP {
    static constexpr int num = Derived::value + 1;
};

struct A : CRTP<A> {
    static constexpr int value = 5;
};

It complains that A does not have a member named value. How to fix the code so that it compiles on both compilers? Or is it illegal altogether?

Aucun commentaire:

Enregistrer un commentaire