Jak*_*dle 5 c++ ambiguity malformed overload-resolution c++11
这是我的代码段:
class Base{};
class Derived : private Base{};
template<class T>
class Wrapper
{
public:
template<typename T2>
Wrapper( T2&& )
{ }
};
// Function declarations
void func( Base& param );
void func( Wrapper<Derived> );
void funcUnambiguous( Wrapper<Derived> );
// Here is the Call:
Derived d = Derived();
func( d ); // <- Error
Run Code Online (Sandbox Code Playgroud)
GCC 4.9给了我: error: 'Base' is an inaccessible base of 'Derived'
而我这样做
Derived d = Derived();
funcUnambiguous( d );
Run Code Online (Sandbox Code Playgroud)
它只是工作正常.
看起来,任何只需要廉价演员的功能,即使是格式错误,也隐藏着隐含但昂贵的演员功能.有人有线索吗?