Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Function template convert

boost::convert — Boost.Convert main deployment interface.

Synopsis

// In header: <boost/convert.hpp>


template<typename TypeOut, typename TypeIn, typename Converter> 
  boost::optional< TypeOut > 
  convert(TypeIn const & value_in, Converter const & converter);

Description

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);

Parameters:

converter

Converter to be used for conversion

value_in

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

Returns:

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


PrevUpHomeNext