File: lexcast_converter.qbk

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (33 lines) | stat: -rw-r--r-- 1,501 bytes parent folder | download | duplicates (8)
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-2022
  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]