lundi 4 novembre 2019

How to extract the types passed in template parameters?

In the below code, I want to replace "something" with something that will allow me to declare the type of 'f' as the second parameter passed in C (while passing C to M's template), i.e., float here.

#include<iostream>
using namespace std;
template<class A, class B>
class C{
    public :
        A a;
        B b;
};
template<class D>
class M{
    public :
        decltype(D::<something>) f;  //!!!!!!!!!!!!!!!!
        void show(){cout<<f;}
};
int main(){
    M<C<int,float>> m;
    m.show();
}

Aucun commentaire:

Enregistrer un commentaire