I wanted to go deeper in template code, but I got an error that I reproduce in the simplified code here :
namespace impl {
template<class T>
struct DefaultPolicy {
static T unwrap(T value) { return value; };
};
}
struct DefaultPolicy {
template <class T> using type = typename impl::DefaultPolicy<T>;
};
template <class T, class Policy>
auto unwrap(T value, Policy) {
using policy_t = typename Policy::type<T>;
return policy_t::unwrap(value);
};
int main() {
unwrap(42, DefaultPolicy{});
}
I have no idea how to correct what looks like a basic syntax error :
error: expected ';' before '<' token
using policy_t = typename Policy::type<T>;
^
However, if I replace the 'Policy' type by 'DefaultPolicy' (what should be done by the compiler ... more or less ?), I got no error.
So, is there a simple syntax solution, or am I trying to do something not possible ?