我在现有类中添加了一个重载方法,现在在单元测试中导致编译错误。
我已使用以下代码复制了该问题:
#include <type_traits>
#include <string>
class Foo
{
public:
Foo() {};
int bar(const std::string & s) {return 1;};
int bar(const std::string & s, long l) {return 2;};
int bar2(const std::string & s) {return 3;};
};
int main()
{
// compiles
std::is_same<std::result_of<decltype(&Foo::bar2)(Foo, const std::string &)>::type, int>::value;
// does not compile
std::is_same<std::result_of<decltype(&Foo::bar)(Foo, const std::string &)>::type, int>::value;
return 0;
}
我需要对未编译的行进行哪些更改才能测试重载方法的返回值?