vendredi 1 juin 2018

C++ template inheritance hides template parameters

template <typename>
struct B
{
    constexpr static int T = 5;
};

template <int T>
struct D : B<int>
{
    constexpr static int value = T;
};

int main()
{
    std::cout << D<7>::value << std::endl;
}

As I have recently learned that template parameters of a template derived class gets checked after the names in the base class scope during lookup. That being said, is there anyway to qualify value to refer to the template parameter T in the derived class?

Aucun commentaire:

Enregistrer un commentaire