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

PrevUpHomeNext

Function template apply

boost::cnv::apply — Boost.Convert deployment interface with algorithms.

Synopsis

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


template<typename TypeOut, typename TypeIn, typename Converter> 
  reference< Converter, TypeOut, TypeIn > apply(Converter const & cnv);

Description

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


PrevUpHomeNext