I am new to using boost::lexical_cast and have minimal understanding of its internals. I am trying to do the following cast:
string someString = boost::lexical_cast<char>(sourceString);
However, boost is complaining that the above code is:
[Exception]: bad lexical cast: source type value could not be interpreted as target
The source is a string, however it will always only be 1 character long.
Could someone please explain?
Thanks.
When I test it (after fixing the invalid conversion from
char
tostring
), the lexical cast succeeds as long assourceString
contains a single character. Here are the test results.If your real code doesn't work, then please post more of it; preferably a runnable program that demonstrates the error.