With mapbox::variant (https://github.com/mapbox/variant/blob/master/include/mapbox/variant.hpp), I can do the following:
using variant = mapbox::util::variant<Args...>;
variant<std::string> v;
// do something with v
...
// Get string from v:
std::string s = v.get<std::string>();
But when I try to implement this by a template function, I got compile error:
template <typename T>
T getValue()
{
variant<T> value{};
// Get value
...
return value.get<T>();
}
GCC complains:
../utils.hpp:52:23: error: expected primary-expression before '>' token return value.get(); ^ ../utils.hpp:52:25: error: expected primary-expression before ')' token return value.get();
What is wrong with the template function?