I often want to get the decltype of a class template argument in order to use it further, like in a loop which I have stripped and simplified to show my problem:
template <typename T>
class Foo {
public:
T type; //This is my hack to get decltype of T
};
template <typename T>
class Bar {
public:
};
int main() {
for(auto& foo : fs) {
//Is there some way to get the decltype of the template without having to refer to some arbitrary T member of Foo?
auto bar = someFunction<decltype(foo.type)>();
}
}
Is there a way to get the decltype of the template argument without doing this hack? If not, what is the best workaround to get the decltype of such a value?