
After changing boost::lexical_cast<unsigned short>(aStr); to boost::lexical_cast<unsigned short>(aStr.c_str()); I had no problem compiling the program. Cheers, Stephan Charles Schwartz schrieb:
fisrt of all: ok, I erred in the // (they did not appear in the original program).
Re: vers., it's boost vers. 1_30_0
here's more info re the error, even admitting your changes:
---------- ------ Build started: Project: UnsignedShort, Configuration: Debug Win32 ------
Compiling... UnsignedShort.cpp c:\Boost\boost_1_30_0\boost\lexical_cast.hpp(147) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion) c:\Boost\boost_1_30_0\boost\lexical_cast.hpp(146) : while compiling class-template member function 'bool boost::detail::lexical_stream
::operator <<(const Source &)' with [ Target=unsigned short, Source=std::string ] c:\Boost\boost_1_30_0\boost\lexical_cast.hpp(189) : see reference to class template instantiation 'boost::detail::lexical_stream ' being compiled with [ Target=unsigned short, Source=std::string ] c:\Documents and Settings\schwartc\My Documents\Visual Studio Projects\boost_lexical_cast\UnsignedShort\UnsignedShort.cpp(12) : see reference to function template instantiation 'Target boost::lexical_cast (Source)' being compiled with [ Target=unsigned short, Source=std::string ] UnsignedShort - 1 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped "Charles Schwartz"
wrote in message news:bhjc0f$c7q$1@sea.gmane.org... If possible, please advise.
using lexical cast w/unsigned short fails, on MSVC7:
#include
#include <iostream> int _tmain(int argc, _TCHAR* argv[]) { std::string aStr("2"); unsigned short i = boost::lexical_cast<unsigned short>(aStr); \\ ERROR!
std::cout << i << std::endl; return 0; }
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/