Boost_lexical_cast

1
2
#include < boost/lexical_cast.hpp>
using namespace boost;
  1. conversion between number and string: replace the atoi, itoa, and etc

    1
    2
    cout<< lexical_cast< string>(i)<< endl;
    cout<< lexical_cast< double>(s)<< endl;
  2. mixed types: for type generalization

    1
    2
    3
    #include < boost/fusion/adapted/boost_tuple.hpp>
    boost::tuple<char, int, char, int> decim('-', 10, 'e', 5);
    assert(stringize(decim) == "-10e5");