Suppose I have a simple template class:
template <typename ElementType, ElementType Element>
class ConsecutiveMatcher
{
public:
bool operator () (ElementType lhs, ElementType rhs)
{
return lhs == Element && rhs == Element;
}
};
I would usually make instantiation simpler than ConsecutiveMatcher<wchar_t, L'\\'>()
by providing a function which can infer the template argument types based on the parameter types:
template <typename ElementType>
ConsecutiveMatcher<ElementType, Element /* ?? */>
MakeConsMatcher(ElementType Element)
{
return ConsecutiveMatcher<ElementType, Element>();
}
However, in this case, MakeConsMatcher(L'\\')
will not work, because the function needs to return a class whose template does not only contain a type, but also a value.
How can I return a class template from a function which has not only type template arguments, but also value template arguments?