]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [/ |
2 | Copyright (c) Vladimir Batov 2009-2016 | |
3 | Distributed under the Boost Software License, Version 1.0. | |
4 | See copy at http://www.boost.org/LICENSE_1_0.txt. | |
5 | ] | |
6 | ||
7 | [import ../example/lexical_cast.cpp] | |
8 | ||
9 | [section:lexical_cast_converter ['boost::cnv::lexical_cast] Converter] | |
10 | ||
11 | The purpose of the converter is to | |
12 | ||
13 | * Make use of the `boost::lexical_cast` functionality and performance that many people have become accustomed to and comfortable with; | |
14 | * Demonstrate how existing independent conversion\/transformation-related facilities might be incorporated in to the ['Boost.Convert] framework. | |
15 | ||
16 | The converter can easily replace `boost::lexical_cast`, adding flexibility and convenience: | |
17 | ||
18 | [lexical_cast_headers1] | |
19 | [lexical_cast_example1] | |
20 | ||
21 | See the [classref boost::cnv::lexical_cast `boost::cnv::lexical_cast` implementation] for details. | |
22 | ||
23 | In order for a user-defined type to be integrated into the `boost::lexical_cast` framework and, consequently, deployed with the `boost::cnv::lexical_cast` converter: | |
24 | ||
25 | * ['TypeOut] needs to be [@http://en.cppreference.com/w/cpp/concept/CopyConstructible ['Copy Constructible]]; | |
26 | * ['TypeOut] needs to be [@http://en.cppreference.com/w/cpp/concept/DefaultConstructible ['Default Constructible]]; | |
27 | * ['TypeOut] needs to be ['Input Streamable]; | |
28 | * ['TypeIn] needs to be ['Output Streamable]. | |
29 | ||
30 | The first two requirements are imposed by the `boost::lexical_cast` design and implementation and the last two requirements by the underlying `std::stringstream` engine. | |
31 | ||
32 | [endsect] | |
33 |