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 deployment interface with the default converter.

Synopsis

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


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

Description

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


PrevUpHomeNext