]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/convert/doc/other.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / convert / doc / other.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:other_conversions Beyond Basic Conversions]
8
9 An interesting (and yet to be fully explored) property of the described design is that ['Boost.Convert] is not limited to string-to-type and type-to-string conversions. The `boost::convert()` interface is type-agnostic and the plugged-in converter ultimately dictates what type transformations are available. Consequently, a wide range of conversion\/transformation-related tasks can be addressed and ['deployed uniformly] by plugging-in special-purpose converters.
10
11 As an experiment, the code below (taken from ['test/encryption.cpp]) does not do type conversion. Instead, it applies a string transformation:
12
13 string encrypted = boost::convert<string>("ABC", my_cypher).value();
14 string decrypted = boost::convert<string>(encrypted, my_cypher).value();
15
16 BOOST_ASSERT(encrypted == "123");
17 BOOST_ASSERT(decrypted == "ABC");
18
19 The original "ABC" string is "encrypted" as "123" first and then "123" is "decrypted" back to its original "ABC" form.
20
21 Similarly, I personally do not immediately see as objectionable string-transformations like:
22
23 std::u8string utf8 = boost::convert<std::u8string>(utf32_str, cnv);
24 std::u8string utf8 = boost::convert<std::u8string>(mbcs_str, cnv);
25
26 [endsect]