# Boost.Convert C++ Reference

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

For example,

    std::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>(std::cref(cnv)).value_or(-1));

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

boost::throw_on_failure is the 'tag' object to request the exception-throwing behavior.

boost::optional< TypeOut > `TypeIn const &

Value of the TypeIn type to be converted to the TypeOut 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 : 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.
std::enable_if< is_convertible< Fallback, TypeOut >::value, TypeOut >::type `TypeIn const &` `Converter const &` `Fallback const &`
std::enable_if< cnv::is_fun< Fallback, TypeOut >::value, 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 > &
derived_type & `argument_pack const &`
void `string_type const &` `optional< out_type > &`
void `in_type` `optional< string_type > &`
derived_type const &
derived_type &
void `argument_pack const &` `keyword_tag` `mpl::false_`
base
adjust
precision
uppercase
skipws
width
fill
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
=8
=10
=16
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 *`
buffer_type
char_type const *
std::size_t
buffer_type
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 &(*)(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 > &`
boost::disable_if< boost::parameter::is_argument_pack< manipulator >, `this_type` & >::type `manipulator`
`this_type` & `manipulator_type`
`this_type` & `std::locale const &`
std::enable_if< boost::parameter::is_argument_pack< argument_pack >::value, `this_type` & >::type `argument_pack const &`
void `in_type const &` `boost::optional< string_type > &`
void `boost::cnv::range< string_type >` `boost::optional< out_type > &`
this_type
&&
this_type
const &
`this_type` & ``this_type` const &`
void `argument_pack const &` `keyword_tag` `mpl::false_`
locale
precision
width
fill
uppercase
skipws
adjust
base
notation
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 *`
boost::cnv::range< char_type * > `double` `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); }
    }