2
0
mirror of https://github.com/boostorg/convert.git synced 2026-01-31 08:02:18 +00:00
Files
convert/example/default_converter.cpp
Vladimir Batov adc32b763e cleanup
2014-07-02 12:12:26 +10:00

31 lines
856 B
C++

// Boost.Convert test and usage example
// Copyright (c) 2009-2014 Vladimir Batov.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt.
#include <boost/convert.hpp>
#include <boost/convert/lexical_cast.hpp>
#include <boost/detail/lightweight_test.hpp>
//[default_converter_declaration
struct boost::cnv::by_default : public boost::cnv::lexical_cast {};
//]
//[default_converter_headers1
using std::string;
using boost::convert;
//]
int
main(int argc, char const* argv[])
{
//[default_converter_example1
// No explicit converter provided. boost::cnv::by_default is used.
int i = convert<int>("123").value();
string s = convert<string>(123).value();
BOOST_TEST(i == 123);
BOOST_TEST(s == "123");
//]
return boost::report_errors();
}