mercredi 17 mars 2021

Partial specialization and const conundrum in C++11

A class template:

template <class X, class Y > class MyTemplate;

I want to partially specialize this class so that when X is a const type, Y is an int and that partial specialization code is chosen if I create an object such as:

MyTemplate<sometype const> var;

whereas if X is a non-const type, Y is a double and that partial specialization code is chosen if I create an object such as:

MyTemplate<sometype> var;

Is this possible in C++11 ? If so, how ? If not, is this possible in C++20 with concepts and requirements ?

Aucun commentaire:

Enregistrer un commentaire