Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
LexicalCast is a convert code snippet to convert std::string to (possibly) any data type. CanCast can check if this conversion is possible.
LexicalCast uses CanCast.
LexicalCast serves the same purpose as boost::lexical_cast, but does not use Boost. Note that there are differences between LexicalCast and boost::lexical_cast, as boost::lexical_cast is more strict.
#include <string> |
The table below shows if a std::string can be converted according to CanCast (CC) and CanLexicalCast (CLC) and what the result will be after LexicalCast (LC) and boost::lexical_cast (l_c). Note that the first std::string was a space (' '). Below the table I show the code I've used to generate this output.
******************************************************************************* |
const std::vector<std::string> GetTests() |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.