在 Visual C++(2008 和 2010)中,以下代码无法编译并出现以下错误:
#include <memory>
void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) )
{
}
class P
{
void
Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) )
{
}
};
错误 C2039:“make_shared”:不是“全局命名空间”的成员
错误 C3861:“make_shared”:找不到标识符
它抱怨 P::Foo() 而不是 ::Foo() 的定义。
有谁知道为什么 Foo() 使用 std::make_shared 而不是 P::Foo() 的默认参数是有效的?