...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::cnv::strtol — std::strtol-based extended converter
// In header: <boost/convert/strtol.hpp> struct strtol : public boost::cnv::cnvbase< boost::cnv::strtol > { // types typedef boost::cnv::strtol this_type; typedef boost::cnv::cnvbase< this_type > base_type; // private member functions template<typename string_type> void str_to(cnv::range< string_type >, optional< int_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< sint_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< lint_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< llint_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< uint_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< usint_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< ulint_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< ullint_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< flt_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< dbl_type > &) const; template<typename string_type> void str_to(cnv::range< string_type >, optional< ldbl_type > &) const; template<typename char_type> cnv::range< char_type * > to_str(int_type, char_type *) const; template<typename char_type> cnv::range< char_type * > to_str(uint_type, char_type *) const; template<typename char_type> cnv::range< char_type * > to_str(lint_type, char_type *) const; template<typename char_type> cnv::range< char_type * > to_str(ulint_type, char_type *) const; template<typename char_type> cnv::range< char_type * > to_str(llint_type, char_type *) const; template<typename char_type> cnv::range< char_type * > to_str(ullint_type, char_type *) const; template<typename char_type> cnv::range< char_type * > to_str(dbl_type, char_type *) const; template<typename char_type, typename in_type> cnv::range< char_type * > i_to_str(in_type, char_type *) const; template<typename string_type, typename out_type> void str_to_i(cnv::range< string_type >, optional< out_type > &) const; template<typename string_type, typename out_type> void str_to_d(cnv::range< string_type >, optional< out_type > &) const; // private static functions static double adjust_fraction(double, int); static int get_char(int); // public member functions template<typename char_type, typename Type> boost::cnv::range< char_type * > i_to_str(Type, char_type *) const; template<typename char_type> boost::cnv::range< char_type * > to_str(double, char_type *) const; template<typename string_type, typename out_type> void str_to_i(cnv::range< string_type >, boost::optional< out_type > &) const; };
The converter offers a fairly decent overall performance and moderate formatting facilities.
strtol
private member functionstemplate<typename string_type> void str_to(cnv::range< string_type > v, optional< int_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< sint_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< lint_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< llint_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< uint_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< usint_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< ulint_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< ullint_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< flt_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< dbl_type > & r) const;
template<typename string_type> void str_to(cnv::range< string_type > v, optional< ldbl_type > & r) const;
template<typename char_type> cnv::range< char_type * > to_str(int_type v, char_type * buf) const;
template<typename char_type> cnv::range< char_type * > to_str(uint_type v, char_type * buf) const;
template<typename char_type> cnv::range< char_type * > to_str(lint_type v, char_type * buf) const;
template<typename char_type> cnv::range< char_type * > to_str(ulint_type v, char_type * buf) const;
template<typename char_type> cnv::range< char_type * > to_str(llint_type v, char_type * buf) const;
template<typename char_type> cnv::range< char_type * > to_str(ullint_type v, char_type * buf) const;
template<typename char_type> cnv::range< char_type * > to_str(dbl_type v, char_type * buf) const;
template<typename char_type, typename in_type> cnv::range< char_type * > i_to_str(in_type, char_type *) const;
template<typename string_type, typename out_type> void str_to_i(cnv::range< string_type >, optional< out_type > &) const;
template<typename string_type, typename out_type> void str_to_d(cnv::range< string_type >, optional< out_type > &) const;
strtol
public member functionstemplate<typename char_type, typename Type> boost::cnv::range< char_type * > i_to_str(Type in_value, char_type * buf) const;
template<typename char_type> boost::cnv::range< char_type * > to_str(double value, char_type * buf) const;
template<typename string_type, typename out_type> void str_to_i(cnv::range< string_type > range, boost::optional< out_type > & result_out) const;