0
我需要從嵌套類型中獲取模板參數。這裏有一個簡單的例子來展示我需要提取的類型。從嵌套類型中提取模板參數的類型特徵
#include <iostream>
#include <typeinfo>
template<typename T>
void function(T) {
// T = 'struct A<int>::B'
//
// Here I want to get the template value type e.g. 'int' from T
// so that this would print 'int'. How can this be done?
std::cout << typeid(T).name() << std::endl;
}
template<typename T>
struct A {
using B = struct { int f; };
};
int main() {
function(A<int>::B{});
return 0;
}
你可以添加一個'的typedef 'B'裏面? – Jarod42