Compile error: unresolved overloaded function type

天涯浪子 提交于 2019-12-05 18:03:55

You need to use the template disambiguator:

return b.template get<&B::t>();

Without it, when parsing the expression:

b.get<&B::t>();

The compiler can't tell whether it should interpret get as the name of a member variable followed by a < sign (less-than), or as the instantiation of a member function template called get.

Although we know what is the intended meaning of our expression, the compiler cannot, at least not before instantiation occurs - and syntactic parsing is performed even though your function is never instantiated.

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