C++ visualc&x2B+;std::reference\u包装中的10.0错误?

C++ visualc&x2B+;std::reference\u包装中的10.0错误?,c++,visual-c++,c++11,pass-by-reference,c++-standard-library,C++,Visual C++,C++11,Pass By Reference,C++ Standard Library,代码: #包括 结构Foo { 虚空mf()=0; }; 结构栏:Foo { 虚空mf(){} }; int main() { 巴罗; 标准:参考包装(o); } MinGW g++4.6.1的结果: [d:\dev\test] >g++foo.cpp-std=c++0x [d:\dev\test] > _ cl foo.cpp foo.cpp C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):

代码:

#包括
结构Foo
{
虚空mf()=0;
};
结构栏:Foo
{
虚空mf(){}
};
int main()
{
巴罗;
标准:参考包装(o);
}
MinGW g++4.6.1的结果:

[d:\dev\test] >g++foo.cpp-std=c++0x [d:\dev\test] > _ 结果 [d:\dev\test] >cl foo.cpp foo.cpp C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xrefwrap(371):请参阅正在编译的类模板实例化“std::tr1::\u Call\u wrapper”的参考 具有 [ _Callable=std::tr1::_Callable_obj ] C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xrefwrap(416):请参阅对正在编译的类模板实例化“std::tr1::\u Refwrap\u impl”的引用 具有 [ _Ty=常福 ] cpp(16):请参阅对正在编译的类模板实例化“std::tr1::reference_wrapper”的引用 具有 [ _Ty=常福 ] C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2027:使用未定义的类型“std:” tr1::_结果_' 具有 [ _Ty=常量Foo(无效) ] C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(9):错误C2143:语法错误:缺少“;”在“(”之前 C:\程序文件(x86)\\微软Visual Studio 10 \vc包含\xCalCalpRead(9):错误C44:缺少类型指定符-int假设。C++:不支持默认int C:\程序文件(x86)\\微软Visual Studio 10 \vc包含\xCalCalpRead(10):错误C44:缺少类型指定符-int假设。C++:不支持默认int C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 C:\ProgramFiles(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8):错误C2259:“Foo”:无法实例化抽象类 由于下列成员: 'void Foo::mf(void)':是抽象的 foo.cpp(5):参见“foo::mf”的声明 [d:\dev\test] > _

我喜欢VisualC++编译器告诉用户11次抽象类不能实例化,只是想把点击到家中,就像用户没有意识到的那样,但是应该<代码> STD::RealthyOnWrasePux/Cuo>真正实例化类吗?引用不需要实例化


这就是我怀疑的,VisualC++标准库实现中的bug?< /p> 问题作者。它是Visual C++ 10中被假定固定在下一个主要版本的VC中。< /P>我提交了一个微软。如果你不创建具有REF帮助函数的RealthyType包装器?“我们已经修复了它,修复程序将在VC11 RTM中提供。(但是,修复程序没有进入VC11测试版。)“想知道VC10会发生什么,是否会出现另一个service pack?你应该回答这个问题,即使它是你的,并接受它。不是为了代表,而是为了完成。答案看起来更像是回答而不是评论(我想知道为什么……嗯)@DavidRodríguez dribeas,我想知道为什么。像这样的网站曾经是沟通的渠道。当它们带来太多的开销,太多的麻烦时,人们就会停止使用它们。你能想象有哪个足够聪明的人能从中受益,需要“帮助”,需要一个如此“答案”?我想

#include <functional>

struct Foo
{
    virtual void mf() = 0;
};

struct Bar: Foo
{
    virtual void mf() {}
};

int main()
{
    Bar o;
    std::reference_wrapper<Foo const> wrapper( o );
}
[d:\dev\test] > g++ foo.cpp -std=c++0x [d:\dev\test] > _ [d:\dev\test] > cl foo.cpp foo.cpp C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xrefwrap(371) : see reference to class template instantiation 'std::tr1::_Call_wrapper' being compiled with [ _Callable=std::tr1::_Callable_obj ] C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xrefwrap(416) : see reference to class template instantiation 'std::tr1::_Refwrap_impl' being compiled with [ _Ty=const Foo ] foo.cpp(16) : see reference to class template instantiation 'std::tr1::reference_wrapper' being compiled with [ _Ty=const Foo ] C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2027: use of undefined type 'std:: tr1::_Result_of' with [ _Ty=const Foo (void) ] C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(9) : error C2143: syntax error : missing ';' before '(' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xxcallwrap(8) : error C2259: 'Foo' : cannot instantiate abstract class due to following members: 'void Foo::mf(void)' : is abstract foo.cpp(5) : see declaration of 'Foo::mf' [d:\dev\test] > _