I have a enum Type that describes methods of parsing some objects. E.g. I can parse "len100" as a string either a enumeration. Nested struct Native takes a template argument that describes a type of the variable in which value will be contained. E.g. "len100" can be saved to string or uint. But this code gives me an error:
"invalid use of incomplete type 'struct Evaluator<(Type)3>::Native<T>'"
on this line:
T Evaluator<Type::jarray>::Native<T>::eval() {
This happens also with the vector specialization. How can I fix this problem and is there a better solution to handle this task?
enum class Type
{
juint
, jstring
, jenum
, jarray
};
template<Type type>
struct Evaluator
{
template<typename T>
struct Native {
static T eval();
};
};
template<>
template<typename T>
T Evaluator<Type::jarray>::Native<T>::eval() {
cout << "primitive" << endl;
return T{};
}
template<>
template<typename T>
T Evaluator<Type::jarray>::Native<vector<T>>::eval() {
cout << "vector" << endl;
return T{};
}
int main() {
Evaluator<Type::jarray>::Native<vector<int>>::eval();
}