C++11 std::future
-
Hi,
ich experimentiere gerade mit VS11 und Threads, und siehe da, ich vermute einen Bug gefunden zu haben. Es geht um diesen Code:
#include <future> #include <iostream> int foo(unsigned a, unsigned b) { return 5; } int main() { std::future<int> f = std::async(foo, 5, 7); std::cout << f.get(); }VS11 DevPreview sagt:
1>C:\Program Files\Microsoft Visual Studio 11.0\VC\include\xrefwrap(96): error C2064: term does not evaluate to a function taking 1 arguments 1> C:\Program Files\Microsoft Visual Studio 11.0\VC\include\xrefwrap(121) : see reference to class template instantiation 'std::_Result_type<__formal,_Fty,<unnamed-symbol>>' being compiled 1> with 1> [ 1> __formal=false, 1> _Fty=int, 1> <unnamed-symbol>=int & 1> ] 1> C:\Program Files\Microsoft Visual Studio 11.0\VC\include\xrefwrap(107) : see reference to class template instantiation 'std::_Result_ofx<_Fty,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t>' being compiled 1> with 1> [ 1> _Fty=int, 1> _V0_t=int &, 1> _V1_t=std::_Nil, 1> _V2_t=std::_Nil, 1> _V3_t=std::_Nil, 1> _V4_t=std::_Nil, 1> _V5_t=std::_Nil 1> ] 1> C:\Program Files\Microsoft Visual Studio 11.0\VC\include\xrefwrap(243) : see reference to class template instantiation 'std::_Result_of<_Fty,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>,_Obj>' being compiled 1> with 1> [ 1> _Fty=int, 1> _V0_t=int &, 1> _V1_t=std::_Nil, 1> _V2_t=std::_Nil, 1> _V3_t=std::_Nil, 1> _V4_t=std::_Nil, 1> _V5_t=std::_Nil, 1> <unnamed-symbol>=std::_Nil, 1> _Obj=std::_Nil 1> ] 1> C:\Program Files\Microsoft Visual Studio 11.0\VC\include\xrefwrap(250) : see reference to class template instantiation 'std::_Result_of0<_Fty>' being compiled 1> with 1> [ 1> _Fty=int (int) 1> ] 1> main.cpp(11) : see reference to class template instantiation 'std::result_of<_Fty>' being compiled 1> with 1> [ 1> _Fty=int (int) 1> ] 1> 1>Build FAILED.Aber GCC sagt: http://ideone.com/ANrPj (Wegen dem runtime_error)
Und? Ist der Code nicht standardkonform? Hat VS11 einen so üblen Bug? Was los hier?

-
cooky451 schrieb:
Und? Ist der Code nicht standardkonform? Hat VS11 einen so üblen Bug? Was los hier?

Du scheinst ja sehr überrascht zu sein, in einer Preview zu einem neuen Standard einen Fehler zu finden (wenn es denn einer ist)...
Probier es man mit
#include <future> #include <iostream> int foo(unsigned a, unsigned b) { return 5; } int main() { auto f = std::async(foo, 5, 7); std::cout << f.get(); }
-
manni66 schrieb:
Du scheinst ja sehr überrascht zu sein, in einer Preview zu einem neuen Standard einen Fehler zu finden (wenn es denn einer ist)...
Nun ja, der Fehler ist ja mehr als offensichtlich.
(Dein Code produziert genau den gleichen Fehler.)