I'm having a little bit of trouble with boost::lexical_cast<bool> and and c-style strings.
char* s = "true";
if( boost::lexical_cast<bool>(s) )
printf("\n True!! \n");
else
printf("\n False!! \n");
Even with something this simple, I keep getting the boost::bad_lexical_cast exception thrown.
Quote:From http://lists.boost.org/Archives/boost/2002/05/30088.php
If we allow implicit conversion (the seconds step), then a careful study of
the conversion rules in C++ is needed, to make sure it does the right thing.
For example, there's an implicit conversion from a pointer, to bool, so
"bool b=lexical_cast<bool>("false")" (when boolalpha is enabled) will always
give true (because the char * pointer is non-null). This needs to be checked
for, and handled, at the "special case" step. That's why that step has to be
first.
Although this isn't exactly my problem, since I'm using a char* string and attempting to convert to bool, I was wondering if this could be the problem. Could it be that because I'm attempting to convert to a boolean, and that it's a char pointer?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper