File: lexcast_converter.qbk

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (33 lines) | stat: -rw-r--r-- 1,501 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[/
  Copyright (c) Vladimir Batov 2009-2016
  Distributed under the Boost Software License, Version 1.0.
  See copy at http://www.boost.org/LICENSE_1_0.txt.
]

[import ../example/lexical_cast.cpp]

[section:lexical_cast_converter ['boost::cnv::lexical_cast] Converter]

The purpose of the converter is to

* Make use of the `boost::lexical_cast` functionality and performance that many people have become accustomed to and comfortable with;
* Demonstrate how existing independent conversion\/transformation-related facilities might be incorporated in to the ['Boost.Convert] framework.

The converter can easily replace `boost::lexical_cast`, adding flexibility and convenience:

[lexical_cast_headers1]
[lexical_cast_example1]

See the [classref boost::cnv::lexical_cast `boost::cnv::lexical_cast` implementation] for details.

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:

* ['TypeOut] needs to be [@http://en.cppreference.com/w/cpp/named_req/CopyConstructible ['Copy Constructible]];
* ['TypeOut] needs to be [@http://en.cppreference.com/w/cpp/named_req/DefaultConstructible ['Default Constructible]];
* ['TypeOut] needs to be ['Input Streamable];
* ['TypeIn] needs to be ['Output Streamable].

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.

[endsect]