问题
I have a struct that looks something like:
struct foo_t
{
template <std::size_t x, std::size_t y>
std::size_t operator()() const
{ return /*something dealing with x and y*/; }
};
The definition seems to compile fine, but how do I call it? I can't seem to get anything past the compiler:
foo_t foo;
foo<3, 3>(); // ERROR: Compiler seems to think I'm asking for "foo < 3 ..."
回答1:
It's ugly, but..,
foo_t foo;
foo.operator()<3, 3>();
Online demo.
来源:https://stackoverflow.com/questions/11105060/how-do-i-call-a-templatized-operator