]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/convert/doc/default_converter.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / convert / doc / default_converter.qbk
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 [section Default Converter]
8
9 [import ../example/default_converter.cpp]
10
11 The explicitly provided converter as in
12
13 int i = boost::convert<int>("123", converter).value();
14
15 provides considerable flexibility, configurability and efficiency. However, in certain contexts that might be not that important or even counter-productive if, for example, an application relies on certain consistent behavior associated with one particular converter type and configuration. To accommodate such a scenario ['Boost.Convert] introduces the concept of the ['default converter] implemented as `boost::cnv::by_default`.
16
17 [important There is no default converter set by default.]
18
19 Consequently, without additional configuration steps the following call will fail to compile:
20
21 int i = boost::convert<int>("123").value(); // No converter provided
22
23 However, after `boost::cnv::by_default` is defined simply as:
24
25 [default_converter_declaration_simple]
26
27 or potentially configured with additional formatting:
28
29 [default_converter_declaration_formatted]
30
31 the code compiles and deploys `boost::cnv::cstream` when `boost::convert()` is called without an explicitly supplied converter:
32
33 [default_converter_example1]
34
35 The trade-off for the convenience is the rigid converter configuration (which in certain contexts might be the desired behavior) and a potential performance impact. When a converter is not provided explicitly, the default converter is created, potentially configured, deployed and destroyed for every `boost::convert()` call. Consequently, if efficiency of this particular component is important, then the implementation of `boost::cnv::by_default` will need to take that into account and to make sure those operations are cheap.
36
37 [endsect]
38