• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Chapter 1. Boost.Convert 2.0</title>
5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="index.html" title="Chapter 1. Boost.Convert 2.0">
8<link rel="next" href="boost_convert/introduction.html" title="Introduction">
9</head>
10<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
11<table cellpadding="2" width="100%"><tr>
12<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
13<td align="center"><a href="../../../../index.html">Home</a></td>
14<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
15<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
16<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
17<td align="center"><a href="../../../../more/index.htm">More</a></td>
18</tr></table>
19<hr>
20<div class="spirit-nav"><a accesskey="n" href="boost_convert/introduction.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
21<div class="chapter">
22<div class="titlepage"><div>
23<div><h2 class="title">
24<a name="convert"></a>Chapter 1. Boost.Convert 2.0</h2></div>
25<div><div class="author"><h3 class="author">
26<span class="firstname">Vladimir</span> <span class="surname">Batov</span>
27</h3></div></div>
28<div><p class="copyright">Copyright © 2009-2016 Vladimir Batov</p></div>
29<div><div class="legalnotice">
30<a name="convert.legal"></a><p>
31        Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>.
32      </p>
33</div></div>
34</div></div>
35<div class="toc">
36<p><b>Table of Contents</b></p>
37<dl class="toc">
38<dt><span class="section"><a href="index.html#boost_convert.rationale">Rationale</a></span></dt>
39<dt><span class="section"><a href="boost_convert/introduction.html">Introduction</a></span></dt>
40<dt><span class="section"><a href="boost_convert/getting_started.html">Getting Started</a></span></dt>
41<dd><dl>
42<dt><span class="section"><a href="boost_convert/getting_started.html#boost_convert.getting_started.basic_deployment">Basic
43      Deployment</a></span></dt>
44<dt><span class="section"><a href="boost_convert/getting_started/flexibility_and_adaptability_to_change.html">Flexibility
45      and Adaptability to Change</a></span></dt>
46<dt><span class="section"><a href="boost_convert/getting_started/basic_conversion_failure_detection.html">Basic
47      Conversion-Failure Detection</a></span></dt>
48</dl></dd>
49<dt><span class="section"><a href="boost_convert/error_detection.html">Better Error Detection</a></span></dt>
50<dt><span class="section"><a href="boost_convert/default_converter.html">Default Converter</a></span></dt>
51<dt><span class="section"><a href="boost_convert/alternative_interface.html">Alternative Interface</a></span></dt>
52<dt><span class="section"><a href="boost_convert/converters.html">Converters</a></span></dt>
53<dt><span class="section"><a href="boost_convert/integration_of_user_types.html">Integration of
54    User-Defined Types</a></span></dt>
55<dt><span class="section"><a href="boost_convert/algorithms.html">Boost.Convert with Standard Algorithms</a></span></dt>
56<dt><span class="section"><a href="boost_convert/performance.html">Performance</a></span></dt>
57<dd><dl>
58<dt><span class="section"><a href="boost_convert/performance.html#boost_convert.performance.converters_compared">Converters
59      Compared</a></span></dt>
60<dt><span class="section"><a href="boost_convert/performance/boost_convert_overhead.html">Boost.Convert
61      Overhead</a></span></dt>
62<dt><span class="section"><a href="boost_convert/performance/the_bigger_picture.html">The Bigger
63      Picture</a></span></dt>
64</dl></dd>
65<dt><span class="section"><a href="boost_convert/other_conversions.html">Beyond Basic Conversions</a></span></dt>
66<dt><span class="section"><a href="boost_convert/converters_detail.html">Converters in Detail</a></span></dt>
67<dd><dl>
68<dt><span class="section"><a href="boost_convert/converters_detail.html#boost_convert.converters_detail.lexical_cast_converter"><span class="emphasis"><em>boost::cnv::lexical_cast</em></span>
69      Converter</a></span></dt>
70<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter.html"><span class="emphasis"><em>boost::cnv::stream</em></span>
71      Converter</a></span></dt>
72<dd><dl>
73<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter.html#boost_convert.converters_detail.stream_converter.formatting_support">Formatting
74        Support</a></span></dt>
75<dd><dl>
76<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter.html#boost_convert.converters_detail.stream_converter.formatting_support.numeric_base">Numeric
77          Base</a></span></dt>
78<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter.html#boost_convert.converters_detail.stream_converter.formatting_support.field_width__fill_character_and_adjustment">Field
79          Width, Fill Character and Adjustment</a></span></dt>
80<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter.html#boost_convert.converters_detail.stream_converter.formatting_support.leading_whitespace_characters">Leading
81          Whitespace Characters</a></span></dt>
82<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter.html#boost_convert.converters_detail.stream_converter.formatting_support.format_of_boolean_values">Format
83          of Boolean Values</a></span></dt>
84</dl></dd>
85<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter/locale_support.html">Locale
86        Support</a></span></dt>
87<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter/supported_string_types.html">Supported
88        String Types</a></span></dt>
89<dd><dl>
90<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter/supported_string_types.html#boost_convert.converters_detail.stream_converter.supported_string_types.wide_string">Wide
91          String</a></span></dt>
92<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter/supported_string_types/custom_string_types.html">Custom
93          String Types</a></span></dt>
94</dl></dd>
95<dt><span class="section"><a href="boost_convert/converters_detail/stream_converter/the___default_constructible__type_requirement.html">The
96        <span class="emphasis"><em>Default Constructible</em></span> Type Requirement</a></span></dt>
97</dl></dd>
98<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter.html"><span class="emphasis"><em>boost::cnv::strtol</em></span>
99      Converter</a></span></dt>
100<dd><dl>
101<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter.html#boost_convert.converters_detail.strtol_converter.basic_deployment">Basic
102        Deployment</a></span></dt>
103<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter/formatting_support.html">Formatting
104        Support</a></span></dt>
105<dd><dl>
106<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter/formatting_support.html#boost_convert.converters_detail.strtol_converter.formatting_support.numeric_base__bin__oct__dec__hex_">Numeric
107          Base (bin, oct, dec, hex)</a></span></dt>
108<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter/formatting_support/field_width__fill_character_and_adjustment.html">Field
109          Width, Fill Character and Adjustment</a></span></dt>
110<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter/formatting_support/leading_whitespace_characters.html">Leading
111          Whitespace Characters</a></span></dt>
112<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter/formatting_support/floating_point_precision.html">Floating-Point
113          Precision</a></span></dt>
114</dl></dd>
115<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter/supported_string_types.html">Supported
116        String Types</a></span></dt>
117<dd><dl>
118<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter/supported_string_types.html#boost_convert.converters_detail.strtol_converter.supported_string_types.wide_string">Wide
119          String</a></span></dt>
120<dt><span class="section"><a href="boost_convert/converters_detail/strtol_converter/supported_string_types/custom_string_types.html">Custom
121          String Types</a></span></dt>
122</dl></dd>
123</dl></dd>
124</dl></dd>
125<dt><span class="section"><a href="boost_convert/design_notes.html">Design
126    Notes</a></span></dt>
127<dd><dl>
128<dt><span class="section"><a href="boost_convert/design_notes.html#boost_convert.design_notes.requirements">Requirements</a></span></dt>
129<dt><span class="section"><a href="boost_convert/design_notes/converter_signature.html">Converter
130      Signature</a></span></dt>
131<dt><span class="section"><a href="boost_convert/design_notes/user_interface_signature.html">User
132      Interface Signature</a></span></dt>
133</dl></dd>
134<dt><span class="section"><a href="boost_convert/supporting_tools.html">Supporting Tools</a></span></dt>
135<dd><dl>
136<dt><span class="section"><a href="boost_convert/supporting_tools.html#boost_convert.supporting_tools.boost__cnv__range">boost::cnv::range</a></span></dt>
137<dt><span class="section"><a href="boost_convert/supporting_tools/boost__cnv__is_range.html">boost::cnv::is_range</a></span></dt>
138<dt><span class="section"><a href="boost_convert/supporting_tools/boost_declare_has_member.html">BOOST_DECLARE_HAS_MEMBER</a></span></dt>
139<dt><span class="section"><a href="boost_convert/supporting_tools/boost_declare_is_callable.html">BOOST_DECLARE_IS_CALLABLE</a></span></dt>
140<dt><span class="section"><a href="boost_convert/supporting_tools/boost__cnv__is_cnv.html">boost::cnv::is_cnv</a></span></dt>
141</dl></dd>
142<dt><span class="section"><a href="boost_convert/supported_compilers.html">Supported Compilers</a></span></dt>
143<dt><span class="section"><a href="boost_convert/acknowledgements.html">Acknowledgements</a></span></dt>
144<dt><span class="section"><a href="boost_convert_c___reference.html">Boost.Convert C++ Reference</a></span></dt>
145<dd><dl>
146<dt><span class="section"><a href="boost_convert_c___reference.html#header.boost.convert_hpp">Header &lt;boost/convert.hpp&gt;</a></span></dt>
147<dd><dl></dl></dd>
148<dt><span class="section"><a href="header/boost/convert/base_hpp.html">Header &lt;boost/convert/base.hpp&gt;</a></span></dt>
149<dd><dl></dl></dd>
150<dt><span class="section"><a href="header/boost/convert/lexical_cast_hpp.html">Header &lt;boost/convert/lexical_cast.hpp&gt;</a></span></dt>
151<dd><dl></dl></dd>
152<dt><span class="section"><a href="header/boost/convert/parameters_hpp.html">Header &lt;boost/convert/parameters.hpp&gt;</a></span></dt>
153<dt><span class="section"><a href="header/boost/convert/printf_hpp.html">Header &lt;boost/convert/printf.hpp&gt;</a></span></dt>
154<dd><dl></dl></dd>
155<dt><span class="section"><a href="header/boost/convert/spirit_hpp.html">Header &lt;boost/convert/spirit.hpp&gt;</a></span></dt>
156<dd><dl></dl></dd>
157<dt><span class="section"><a href="header/boost/convert/stream_hpp.html">Header &lt;boost/convert/stream.hpp&gt;</a></span></dt>
158<dd><dl></dl></dd>
159<dt><span class="section"><a href="header/boost/convert/strtol_hpp.html">Header &lt;boost/convert/strtol.hpp&gt;</a></span></dt>
160<dd><dl></dl></dd>
161<dt><span class="section"><a href="header/boost/make_default_hpp.html">Header &lt;boost/make_default.hpp&gt;</a></span></dt>
162<dd><dl></dl></dd>
163</dl></dd>
164<dt><span class="section"><a href="index/s18.html">Index</a></span></dt>
165</dl>
166</div>
167<div class="section">
168<div class="titlepage"><div><div><h2 class="title" style="clear: both">
169<a name="boost_convert.rationale"></a><a class="link" href="index.html#boost_convert.rationale" title="Rationale">Rationale</a>
170</h2></div></div></div>
171<p>
172      I was using textual configuration files extensively and was also processing
173      and preparing considerable amounts of data in XML. Consequently, I had a need
174      for an <span class="emphasis"><em>extendible</em></span> library that would provide a <span class="emphasis"><em>uniform</em></span>
175      interface to convert various data between their internal binary representations
176      and external (predominantly textual) representations.
177    </p>
178<p>
179      The <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code> library (with its orthogonal
180      and extendible design) looked very promising compared to others (see <a href="http://www.gotw.ca/publications/mill19.htm" target="_top">The String Formatters of Manor
181      Farm</a> by H. Sutter for the discussion of alternatives). Unfortunately,
182    </p>
183<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
184<li class="listitem">
185          many deployed user types simply did not meet <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code>
186          requirements (namely, <a href="http://en.cppreference.com/w/cpp/named_req/DefaultConstructible" target="_top"><span class="emphasis"><em>Default
187          Constructibility</em></span></a>);
188        </li>
189<li class="listitem">
190          failure to convert a user-provided configuration parameter was not that
191          rare or exceptional to justify the hassle and the overhead of exception
192          processing; consequently, additional flexibility (<span class="emphasis"><em>if</em></span>,
193          <span class="emphasis"><em>when</em></span> and <span class="emphasis"><em>how</em></span>) in handling conversion
194          failures was needed;
195        </li>
196<li class="listitem">
197          additional conversion-related functionality (such as formatting and locale
198          support) were needed.
199        </li>
200</ul></div>
201<p>
202      The original hope was to see <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code>
203      extended to be applicable to a wider range of deployment scenarios. However,
204      after discussions with Kevlin Henney (the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code>
205      author) and in the Boost Developers forum it was collectively decided that
206      the desired extensions were not compatible with the original design and the
207      idea of what <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code> embodied and, therefore, a new
208      component with richer interface and functionality was needed. That decision
209      resulted in the development of <span class="emphasis"><em>Boost.Convert</em></span> described
210      in this document.
211    </p>
212</div>
213</div>
214<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
215<td align="left"><p><small>Last revised: August 11, 2020 at 15:01:23 GMT</small></p></td>
216<td align="right"><div class="copyright-footer"></div></td>
217</tr></table>
218<hr>
219<div class="spirit-nav"><a accesskey="n" href="boost_convert/introduction.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
220</body>
221</html>
222