How do I call a templatized operator()()?

做~自己de王妃 提交于 2020-01-25 00:19:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!