# Boost.Convert C++ Reference

`reference`
`this_type` & `TypeOut const &`
TypeOut `TypeIn const &`
Converter const &
Converter
TypeOut
void
`reference`
`this_type` & `TypeOut const &`
TypeOut `TypeIn const &`
Converter const &
`reference`< Converter, TypeOut, TypeIn > `Converter const &` Boost.Convert deployment interface with algorithms.

For example,

        boost::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
        std::vector<int>             ints;
        boost::cnv::cstream           cnv;

        cnv(std::hex)(std::skipws);

        std::transform(
            strs.begin(),
            strs.end(),
            std::back_inserter(ints),
            boost::cnv::apply<int>(boost::cref(cnv)).value_or(-1));

`reference`< Converter, TypeOut, void > `Converter const &`
unspecified

The boost::throw_on_failure is the name of an object of the boost::detail::throw_on_failure type that is used to indicate desired exception-throwing behavior.

boost::optional< TypeOut > `TypeIn const &

Value of the TypeIn type to be converted to the TyeOut type

` `Converter const &

Converter to be used for conversion

` Boost.Convert main deployment interface.

For example,

        boost::cnv::cstream cnv;

        boost::optional<int>    i = boost::convert<int>("12", cnv);
        boost::optional<string> s = boost::convert<string>(123.456, cnv);

boost::optional<TypeOut> result of conversion together with the indication of success or failure of the conversion request.

boost::optional< TypeOut > `TypeIn const &` Boost.Convert deployment interface with the default converter.

For example,

        struct boost::cnv::by_default : public boost::cnv::cstream {};

        // boost::cnv::cstream (through boost::cnv::by_default) is deployed
        // as the default converter when no converter is provided explicitly.
        boost::optional<int>    i = boost::convert<int>("12");
        boost::optional<string> s = boost::convert<string>(123.456);

TypeOut `TypeIn const &` `Converter const &` `unspecified` Boost.Convert non-optional deployment interface.
enable_if< is_convertible< Fallback, TypeOut >, TypeOut >::type `TypeIn const &` `Converter const &` `Fallback const &`
enable_if< cnv::is_fun< Fallback, TypeOut >, TypeOut >::type `TypeIn const &` `Converter const &` `Fallback`
`cnvbase`
int
unsigned int
long int
unsigned long int
short int
unsigned short int
long long int
unsigned long long int
float
double
long double
void `type_in const &` `boost::optional< type_out > &`
int_type
optional< string_type > &
uint_type
optional< string_type > &
lint_type
optional< string_type > &
llint_type
optional< string_type > &
ulint_type
optional< string_type > &
ullint_type
optional< string_type > &
sint_type
optional< string_type > &
usint_type
optional< string_type > &
flt_type
optional< string_type > &
dbl_type
optional< string_type > &
ldbl_type
optional< string_type > &
string_type const &
optional< int_type > &
string_type const &
optional< uint_type > &
string_type const &
optional< lint_type > &
string_type const &
optional< llint_type > &
string_type const &
optional< ulint_type > &
string_type const &
optional< ullint_type > &
string_type const &
optional< sint_type > &
string_type const &
optional< usint_type > &
string_type const &
optional< flt_type > &
string_type const &
optional< dbl_type > &
string_type const &
optional< ldbl_type > &
base
base::type
adjust
adjust::type
precision
int
precision
int
uppercase
bool
skipws
bool
width
int
fill
char
void `string_type const &` `optional< out_type > &`
void `in_type` `optional< string_type > &`
void `char_type *` `char_type *&` `char_type *&`
derived_type const &
derived_type &
boost::lexical_cast-based converter

The purpose of the converter is to Make use of the boost::lexical_cast functionality and performance that many people have become accustomed to and comfortable with; Demonstrate how existing independent conversion/transformation-related facilities might be The converter can easily replace boost::lexical_cast, adding flexibility and convenience.

void `TypeIn const &` `boost::optional< TypeOut > &`
2
10
16
8
boost::cnv::cnvbase< boost::cnv::printf >
`boost::cnv::printf`
`boost::cnv::cnvbase`< `this_type` >
cnv::range< char * > `in_type` `char *`
void `cnv::range< string_type >` `optional< out_type > &`
int
char const * `int`
char const * `int`
boost::cnv::cnvbase< boost::cnv::spirit >
`boost::cnv::spirit`
`boost::cnv::cnvbase`< `this_type` >
void `cnv::range< string_type >` `optional< out_type > &`
cnv::range< char_type * > `in_type` `char_type *`
char_type const *
std::size_t
Char
`boost::cnv::basic_stream`< char_type >
std::basic_stringstream< char_type >
std::basic_istream< char_type >
std::basic_streambuf< char_type >
std::basic_string< char_type >
std::ios_base &(*
type const &
optional< string_type > &
string_type const &
optional< type > &
void `char_type const *` `optional< type > &`
void `stdstr_type const &` `optional< type > &`
`this_type` & `manipulator`
`this_type` & `manipulator_type`
`this_type` & `std::locale const &`
locale
std::locale
precision
int
precision
int
width
int
fill
char
uppercase
bool
skipws
bool
adjust
boost::cnv::adjust::type
base
boost::cnv::base::type
notation
boost::cnv::notation::type
void `in_type const &` `boost::optional< string_type > &`
void `boost::cnv::range< string_type >` `boost::optional< out_type > &`
this_type
&&
void `cnv::range< string_type >` `optional< out_type > &`
void `in_type const &` `optional< string_type > &`
`boost::cnv::basic_stream`< char >
`boost::cnv::basic_stream`< wchar_t >
boost::cnv::cnvbase< boost::cnv::strtol >
std::strtol-based extended converter

The converter offers a fairly decent overall performance and moderate formatting facilities.

`boost::cnv::strtol`
`boost::cnv::cnvbase`< `this_type` >
void `cnv::range< string_type >` `optional< int_type > &`
void `cnv::range< string_type >` `optional< sint_type > &`
void `cnv::range< string_type >` `optional< lint_type > &`
void `cnv::range< string_type >` `optional< llint_type > &`
void `cnv::range< string_type >` `optional< uint_type > &`
void `cnv::range< string_type >` `optional< usint_type > &`
void `cnv::range< string_type >` `optional< ulint_type > &`
void `cnv::range< string_type >` `optional< ullint_type > &`
void `cnv::range< string_type >` `optional< flt_type > &`
void `cnv::range< string_type >` `optional< dbl_type > &`
void `cnv::range< string_type >` `optional< ldbl_type > &`
cnv::range< char_type * > `int_type` `char_type *`
cnv::range< char_type * > `uint_type` `char_type *`
cnv::range< char_type * > `lint_type` `char_type *`
cnv::range< char_type * > `ulint_type` `char_type *`
cnv::range< char_type * > `llint_type` `char_type *`
cnv::range< char_type * > `ullint_type` `char_type *`
cnv::range< char_type * > `dbl_type` `char_type *`
cnv::range< char_type * > `in_type` `char_type *`
void `cnv::range< string_type >` `optional< out_type > &`
void `cnv::range< string_type >` `optional< out_type > &`
double `double` `int`
int `int`
boost::cnv::range< char_type * > `Type` `char_type *`
void `cnv::range< string_type >` `boost::optional< out_type > &`
T

A considerable number of libraries require an instance of a class provided (storage created and initialized). For example,

        Type result;
        ...
        istream >> result;

In generic code that results in the Default Constructibility requirement imposed on every type 'Type' to be used with the respective code. Inevitably, that requirement a) either excludes all the classes that for various reasons do not meet that requirement or b) imposes certain (not necessarily desirable) design/implementation onto respective classes.

Deployment of boost::make_default() eliminates the Default Constructibility requirement with

        Type result = boost::make_default<Type>();
        ...
        istream >> result;

Classes with no default constructor can now be included via a boost::make_default() specialization:

     namespace boost
     {
         template<> inline Type make_default<Type>() { return Type(parameters); }
     }