boost::indeterminate and std::vector::emplace_back()

Hi, there is a problem when using boost::indeterminate in conjunction with std::vector::emplace_back: std::vector<boost::tribool> v; v.emplace_back(boost::indeterminate); In VS2010, this code causes error C2383: '_Valty' : default-arguments are not allowed on this symbol The error occurs becasue emplace_back's _Valty template parameter is deduced as the type of boost::indeterminate which is a function with a default argument. What is the recommended way to explicitly create an "indeterminate" tribool value in cases like this? Regards, Arno -- Dr. Arno Schödl | aschoedl@think-cell.com Technical Director think-cell Software GmbH | Chausseestr. 8/E | 10115 Berlin | Germany http://www.think-cell.com | phone +49 30 666473-10 | US phone +1 800 891 8091 Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl

[Arno Schödl]
there is a problem when using boost::indeterminate in conjunction with std::vector::emplace_back: std::vector<boost::tribool> v; v.emplace_back(boost::indeterminate); In VS2010, this code causes error C2383: '_Valty' : default-arguments are not allowed on this symbol The error occurs becasue emplace_back's _Valty template parameter is deduced as the type of boost::indeterminate which is a function with a default argument.
I observe that this doesn't compile with VC10 SP1 and Boost 1.49.0, but it DOES compile with my current build of VC11. I believe that a compiler bug was fixed here - there were several things wrong with VC10 SP1's emplace_back() (it was implemented for only 1 argument, and it was also incorrectly overloaded), but its core functionality of perfect forwarding appears to have been correct. Nothing should stop you from passing a function to a perfect forwarder, even a function with default arguments, as long as the function is not overloaded and not a template (otherwise it would be ambiguous which one you want, and there would be no context to disambiguate - you would have to manually static_cast). Stephan T. Lavavej Visual C++ Libraries Developer
participants (2)
-
Arno Schödl
-
Stephan T. Lavavej