From ec5c9e84ffafd1bf75f46c55f7312efef00a3dfc Mon Sep 17 00:00:00 2001 From: Vladimir Batov Date: Sun, 13 Sep 2020 17:58:32 +1000 Subject: [PATCH] 13SEP-17:58 merged from develop --- .gitignore | 1 - doc/00_main.qbk | 6 +- doc/acknowledgments.qbk | 2 +- doc/algorithms.qbk | 4 +- doc/converters.qbk | 2 +- doc/converters_detail.qbk | 2 +- doc/default_converter.qbk | 2 +- doc/design_notes.qbk | 2 +- doc/generate-html.sh | 2 +- doc/getting_serious.qbk | 2 +- doc/getting_started.qbk | 2 +- doc/html/BOOST_CNV_PARAM_idm10939.html | 48 + doc/html/BOOST_CNV_PARAM_idm10941.html | 48 + doc/html/BOOST_CNV_PARAM_idm10945.html | 48 + doc/html/BOOST_CNV_PARAM_idm10967.html | 48 + doc/html/BOOST_CNV_PARAM_idm11238.html | 48 + doc/html/BOOST_CNV_PARAM_idm11240.html | 48 + doc/html/BOOST_CNV_PARAM_idm11244.html | 48 + doc/html/BOOST_CNV_PARAM_idm11266.html | 48 + doc/html/BOOST_CNV_STRING_ENABLE.html | 48 + doc/html/BOOST_CNV_STRING_TO.html | 48 + doc/html/BOOST_CNV_TO_STRING.html | 48 + doc/html/BOOST_CN_idm46323349411056.html | 48 + doc/html/BOOST_CN_idm46323349539088.html | 48 + doc/html/boost/cnv/apply_idm10601.html | 67 ++ doc/html/boost/cnv/apply_idm10603.html | 67 ++ doc/html/boost/cnv/apply_idm10607.html | 67 ++ doc/html/boost/cnv/apply_idm10629.html | 67 ++ .../boost/cnv/apply_idm46323361464960.html | 67 ++ doc/html/boost/cnv/basic_stream.html | 156 ++++ .../boost/cnv/basic_stream/ibuffer_type.html | 63 ++ .../boost/cnv/basic_stream/obuffer_type.html | 51 ++ doc/html/boost/cnv/cnvbase.html | 166 ++++ doc/html/boost/cnv/lexical_cast.html | 71 ++ doc/html/boost/cnv/printf.html | 87 ++ .../boost/cnv/referenc_idm46323361474640.html | 77 ++ doc/html/boost/cnv/reference.html | 77 ++ .../boost/cnv/reference_Convert_idm10575.html | 77 ++ .../boost/cnv/reference_Convert_idm10577.html | 77 ++ .../boost/cnv/reference_Convert_idm10581.html | 77 ++ .../boost/cnv/reference_Convert_idm10603.html | 77 ++ doc/html/boost/cnv/spirit.html | 73 ++ doc/html/boost/cnv/strtol.html | 183 ++++ doc/html/boost/convert_idm10627.html | 94 ++ doc/html/boost/convert_idm10629.html | 94 ++ doc/html/boost/convert_idm10633.html | 94 ++ doc/html/boost/convert_idm10647.html | 62 ++ doc/html/boost/convert_idm10649.html | 62 ++ doc/html/boost/convert_idm10653.html | 62 ++ doc/html/boost/convert_idm10655.html | 94 ++ doc/html/boost/convert_idm10675.html | 62 ++ doc/html/boost/convert_idm46323361447440.html | 62 ++ doc/html/boost/convert_idm46323361454688.html | 94 ++ doc/html/boost/make_default.html | 70 ++ doc/html/boost/throw_on_failure.html | 52 ++ doc/html/boost_convert/acknowledgements.html | 79 ++ doc/html/boost_convert/algorithms.html | 258 ++++++ .../boost_convert/alternative_interface.html | 110 +++ doc/html/boost_convert/converters.html | 190 ++++ doc/html/boost_convert/converters_detail.html | 185 ++++ .../converters_detail/stream_converter.html | 385 ++++++++ .../stream_converter/locale_support.html | 93 ++ .../supported_string_types.html | 87 ++ .../custom_string_types.html | 92 ++ ...fault_constructible__type_requirement.html | 152 ++++ .../converters_detail/strtol_converter.html | 114 +++ .../strtol_converter/formatting_support.html | 93 ++ ..._width__fill_character_and_adjustment.html | 74 ++ .../floating_point_precision.html | 57 ++ .../leading_whitespace_characters.html | 59 ++ .../supported_string_types.html | 71 ++ .../custom_string_types.html | 77 ++ doc/html/boost_convert/default_converter.html | 118 +++ doc/html/boost_convert/design_notes.html | 138 +++ .../design_notes/converter_signature.html | 89 ++ .../user_interface_signature.html | 201 +++++ doc/html/boost_convert/error_detection.html | 182 ++++ doc/html/boost_convert/getting_started.html | 143 +++ .../basic_conversion_failure_detection.html | 168 ++++ ...lexibility_and_adaptability_to_change.html | 128 +++ .../integration_of_user_types.html | 206 +++++ doc/html/boost_convert/introduction.html | 197 ++++ doc/html/boost_convert/other_conversions.html | 72 ++ doc/html/boost_convert/performance.html | 139 +++ .../performance/boost_convert_overhead.html | 118 +++ .../performance/the_bigger_picture.html | 118 +++ .../boost_convert/supported_compilers.html | 73 ++ doc/html/boost_convert/supporting_tools.html | 73 ++ .../supporting_tools/boost__cnv__is_cnv.html | 45 + .../boost__cnv__is_range.html | 45 + .../boost_declare_has_member.html | 91 ++ .../boost_declare_is_callable.html | 130 +++ doc/html/boost_convert_c___reference.html | 97 ++ doc/html/header/boost/convert/base_hpp.html | 51 ++ .../boost/convert/lexical_cast_hpp.html | 46 + .../header/boost/convert/parameters_hpp.html | 53 ++ doc/html/header/boost/convert/printf_hpp.html | 46 + doc/html/header/boost/convert/spirit_hpp.html | 46 + doc/html/header/boost/convert/stream_hpp.html | 53 ++ doc/html/header/boost/convert/strtol_hpp.html | 46 + doc/html/header/boost/make_default_hpp.html | 44 + doc/html/index.html | 230 +++++ doc/html/index/s18.html | 853 ++++++++++++++++++ doc/html/standalone_HTML.manifest | 68 ++ doc/index.idx | 18 +- doc/introduction.qbk | 2 +- doc/jamfile.v2 | 5 +- doc/lexcast_converter.qbk | 2 +- doc/limitations.qbk | 2 +- doc/no_optional_interface.qbk | 2 +- doc/other.qbk | 2 +- doc/performance.qbk | 2 +- doc/rationale.qbk | 2 +- doc/section-end.qbk | 2 +- doc/stream_converter.qbk | 2 +- doc/strtol_converter.qbk | 2 +- doc/tools.qbk | 2 +- doc/user_types.qbk | 2 +- example/algorithms.cpp | 48 +- example/default_converter.cpp | 2 +- example/default_converter_fail.cpp | 2 +- example/getting_serious.cpp | 2 +- example/getting_started.cpp | 40 +- example/lexical_cast.cpp | 2 +- example/stream.cpp | 2 +- include/boost/convert.hpp | 24 +- include/boost/convert/base.hpp | 84 +- include/boost/convert/detail/char.hpp | 2 +- include/boost/convert/detail/config.hpp | 8 +- include/boost/convert/detail/has_member.hpp | 2 +- include/boost/convert/detail/is_callable.hpp | 2 +- include/boost/convert/detail/is_converter.hpp | 2 +- include/boost/convert/detail/is_fun.hpp | 2 +- include/boost/convert/detail/is_string.hpp | 2 +- include/boost/convert/detail/range.hpp | 2 +- include/boost/convert/lexical_cast.hpp | 2 +- include/boost/convert/parameters.hpp | 5 +- include/boost/convert/printf.hpp | 2 +- include/boost/convert/spirit.hpp | 2 +- include/boost/convert/stream.hpp | 77 +- include/boost/convert/strtol.hpp | 9 +- include/boost/make_default.hpp | 2 +- index.html | 2 +- makefile | 4 +- test/callable.cpp | 15 +- test/encryption.cpp | 2 +- test/fallbacks.cpp | 13 +- test/has_member.cpp | 2 +- test/is_converter.cpp | 2 +- test/jamfile.v2 | 2 +- test/lcast_converter.cpp | 2 +- test/performance.cpp | 32 +- test/performance_spirit.cpp | 4 +- test/prepare.hpp | 14 +- test/printf_converter.cpp | 2 +- test/sfinae.cpp | 2 +- test/spirit_converter.cpp | 2 +- test/str_to_int.cpp | 54 +- test/stream_converter.cpp | 6 +- test/strtol_converter.cpp | 4 +- test/test.hpp | 12 +- test/user_type.cpp | 23 +- 162 files changed, 9771 insertions(+), 285 deletions(-) create mode 100644 doc/html/BOOST_CNV_PARAM_idm10939.html create mode 100644 doc/html/BOOST_CNV_PARAM_idm10941.html create mode 100644 doc/html/BOOST_CNV_PARAM_idm10945.html create mode 100644 doc/html/BOOST_CNV_PARAM_idm10967.html create mode 100644 doc/html/BOOST_CNV_PARAM_idm11238.html create mode 100644 doc/html/BOOST_CNV_PARAM_idm11240.html create mode 100644 doc/html/BOOST_CNV_PARAM_idm11244.html create mode 100644 doc/html/BOOST_CNV_PARAM_idm11266.html create mode 100644 doc/html/BOOST_CNV_STRING_ENABLE.html create mode 100644 doc/html/BOOST_CNV_STRING_TO.html create mode 100644 doc/html/BOOST_CNV_TO_STRING.html create mode 100644 doc/html/BOOST_CN_idm46323349411056.html create mode 100644 doc/html/BOOST_CN_idm46323349539088.html create mode 100644 doc/html/boost/cnv/apply_idm10601.html create mode 100644 doc/html/boost/cnv/apply_idm10603.html create mode 100644 doc/html/boost/cnv/apply_idm10607.html create mode 100644 doc/html/boost/cnv/apply_idm10629.html create mode 100644 doc/html/boost/cnv/apply_idm46323361464960.html create mode 100644 doc/html/boost/cnv/basic_stream.html create mode 100644 doc/html/boost/cnv/basic_stream/ibuffer_type.html create mode 100644 doc/html/boost/cnv/basic_stream/obuffer_type.html create mode 100644 doc/html/boost/cnv/cnvbase.html create mode 100644 doc/html/boost/cnv/lexical_cast.html create mode 100644 doc/html/boost/cnv/printf.html create mode 100644 doc/html/boost/cnv/referenc_idm46323361474640.html create mode 100644 doc/html/boost/cnv/reference.html create mode 100644 doc/html/boost/cnv/reference_Convert_idm10575.html create mode 100644 doc/html/boost/cnv/reference_Convert_idm10577.html create mode 100644 doc/html/boost/cnv/reference_Convert_idm10581.html create mode 100644 doc/html/boost/cnv/reference_Convert_idm10603.html create mode 100644 doc/html/boost/cnv/spirit.html create mode 100644 doc/html/boost/cnv/strtol.html create mode 100644 doc/html/boost/convert_idm10627.html create mode 100644 doc/html/boost/convert_idm10629.html create mode 100644 doc/html/boost/convert_idm10633.html create mode 100644 doc/html/boost/convert_idm10647.html create mode 100644 doc/html/boost/convert_idm10649.html create mode 100644 doc/html/boost/convert_idm10653.html create mode 100644 doc/html/boost/convert_idm10655.html create mode 100644 doc/html/boost/convert_idm10675.html create mode 100644 doc/html/boost/convert_idm46323361447440.html create mode 100644 doc/html/boost/convert_idm46323361454688.html create mode 100644 doc/html/boost/make_default.html create mode 100644 doc/html/boost/throw_on_failure.html create mode 100644 doc/html/boost_convert/acknowledgements.html create mode 100644 doc/html/boost_convert/algorithms.html create mode 100644 doc/html/boost_convert/alternative_interface.html create mode 100644 doc/html/boost_convert/converters.html create mode 100644 doc/html/boost_convert/converters_detail.html create mode 100644 doc/html/boost_convert/converters_detail/stream_converter.html create mode 100644 doc/html/boost_convert/converters_detail/stream_converter/locale_support.html create mode 100644 doc/html/boost_convert/converters_detail/stream_converter/supported_string_types.html create mode 100644 doc/html/boost_convert/converters_detail/stream_converter/supported_string_types/custom_string_types.html create mode 100644 doc/html/boost_convert/converters_detail/stream_converter/the___default_constructible__type_requirement.html create mode 100644 doc/html/boost_convert/converters_detail/strtol_converter.html create mode 100644 doc/html/boost_convert/converters_detail/strtol_converter/formatting_support.html create mode 100644 doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/field_width__fill_character_and_adjustment.html create mode 100644 doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/floating_point_precision.html create mode 100644 doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/leading_whitespace_characters.html create mode 100644 doc/html/boost_convert/converters_detail/strtol_converter/supported_string_types.html create mode 100644 doc/html/boost_convert/converters_detail/strtol_converter/supported_string_types/custom_string_types.html create mode 100644 doc/html/boost_convert/default_converter.html create mode 100644 doc/html/boost_convert/design_notes.html create mode 100644 doc/html/boost_convert/design_notes/converter_signature.html create mode 100644 doc/html/boost_convert/design_notes/user_interface_signature.html create mode 100644 doc/html/boost_convert/error_detection.html create mode 100644 doc/html/boost_convert/getting_started.html create mode 100644 doc/html/boost_convert/getting_started/basic_conversion_failure_detection.html create mode 100644 doc/html/boost_convert/getting_started/flexibility_and_adaptability_to_change.html create mode 100644 doc/html/boost_convert/integration_of_user_types.html create mode 100644 doc/html/boost_convert/introduction.html create mode 100644 doc/html/boost_convert/other_conversions.html create mode 100644 doc/html/boost_convert/performance.html create mode 100644 doc/html/boost_convert/performance/boost_convert_overhead.html create mode 100644 doc/html/boost_convert/performance/the_bigger_picture.html create mode 100644 doc/html/boost_convert/supported_compilers.html create mode 100644 doc/html/boost_convert/supporting_tools.html create mode 100644 doc/html/boost_convert/supporting_tools/boost__cnv__is_cnv.html create mode 100644 doc/html/boost_convert/supporting_tools/boost__cnv__is_range.html create mode 100644 doc/html/boost_convert/supporting_tools/boost_declare_has_member.html create mode 100644 doc/html/boost_convert/supporting_tools/boost_declare_is_callable.html create mode 100644 doc/html/boost_convert_c___reference.html create mode 100644 doc/html/header/boost/convert/base_hpp.html create mode 100644 doc/html/header/boost/convert/lexical_cast_hpp.html create mode 100644 doc/html/header/boost/convert/parameters_hpp.html create mode 100644 doc/html/header/boost/convert/printf_hpp.html create mode 100644 doc/html/header/boost/convert/spirit_hpp.html create mode 100644 doc/html/header/boost/convert/stream_hpp.html create mode 100644 doc/html/header/boost/convert/strtol_hpp.html create mode 100644 doc/html/header/boost/make_default_hpp.html create mode 100644 doc/html/index.html create mode 100644 doc/html/index/s18.html create mode 100644 doc/html/standalone_HTML.manifest diff --git a/.gitignore b/.gitignore index e596875..b2d6602 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ bin.v2/ bin/ doc/bin/ -doc/html/ doc/doxygen/ doc/inspect.txt convert.pdf diff --git a/doc/00_main.qbk b/doc/00_main.qbk index 7685aaf..73efed4 100644 --- a/doc/00_main.qbk +++ b/doc/00_main.qbk @@ -1,5 +1,5 @@ [/============================================================================== - Copyright (C) 2009-2016 Vladimir Batov + Copyright (C) 2009-2020 Vladimir Batov Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See a copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ [version 2.0] [id convert] [dirname convert] - [copyright 2009-2016 Vladimir Batov] + [copyright 2009-2020 Vladimir Batov] [purpose Conversions Beyond boost::lexical_cast] [category generic] [authors [Batov, Vladimir]] @@ -21,6 +21,8 @@ ] ] +[important Requires C++11 and up.] + [import ../test/test.hpp] [import ../example/stream.cpp] [import ../test/stream_converter.cpp] diff --git a/doc/acknowledgments.qbk b/doc/acknowledgments.qbk index ca48381..72921dc 100644 --- a/doc/acknowledgments.qbk +++ b/doc/acknowledgments.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/algorithms.qbk b/doc/algorithms.qbk index d9ab9cd..33881b6 100644 --- a/doc/algorithms.qbk +++ b/doc/algorithms.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] @@ -24,7 +24,7 @@ The `boost::cnv::apply` with forced (rather than deduced) ['Typ [algorithm_example7] -[note For demonstration purposes the example above is made as simple as possible and, consequently, the described "issue" could probably be addressed by other means. Still, do not let my inability to come up with a better (complex but short and succulent) example get in the way of appreciating the described functionality. I do not expect it to be used often but it is here when you need it.] +[note For demonstration purposes the example above is made as simple as possible and, consequently, the described "issue" could probably be addressed by other means. Still, do not let my inability to come up with a better (complex but short and representative) example get in the way of appreciating the described functionality. I do not expect it to be used often but it is here when you need it.] [endsect] [/section:algorithms Boost.Convert with Standard Algorithms] diff --git a/doc/converters.qbk b/doc/converters.qbk index ed8c8a8..f99b124 100644 --- a/doc/converters.qbk +++ b/doc/converters.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/converters_detail.qbk b/doc/converters_detail.qbk index 876434e..e0376e6 100644 --- a/doc/converters_detail.qbk +++ b/doc/converters_detail.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/default_converter.qbk b/doc/default_converter.qbk index 75008f6..d129bc7 100644 --- a/doc/default_converter.qbk +++ b/doc/default_converter.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/design_notes.qbk b/doc/design_notes.qbk index 48994e9..00cb6ba 100644 --- a/doc/design_notes.qbk +++ b/doc/design_notes.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/generate-html.sh b/doc/generate-html.sh index deaf630..0b93f51 100755 --- a/doc/generate-html.sh +++ b/doc/generate-html.sh @@ -7,7 +7,7 @@ else export BOOST_ROOT=$HOME/dev/boost fi -$BOOST_ROOT/bjam --toolset=gcc --enable-index +$BOOST_ROOT/b2 --toolset=gcc --enable-index rm -rf convert_reference.xml rm -rf bin diff --git a/doc/getting_serious.qbk b/doc/getting_serious.qbk index 0b0573d..51636fb 100644 --- a/doc/getting_serious.qbk +++ b/doc/getting_serious.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/getting_started.qbk b/doc/getting_started.qbk index b7479a1..d9cad77 100644 --- a/doc/getting_started.qbk +++ b/doc/getting_started.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/html/BOOST_CNV_PARAM_idm10939.html b/doc/html/BOOST_CNV_PARAM_idm10939.html new file mode 100644 index 0000000..60b5220 --- /dev/null +++ b/doc/html/BOOST_CNV_PARAM_idm10939.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/base.hpp>
+
+BOOST_CNV_PARAM(param_name, param_type)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_PARAM_idm10941.html b/doc/html/BOOST_CNV_PARAM_idm10941.html new file mode 100644 index 0000000..a6dadbc --- /dev/null +++ b/doc/html/BOOST_CNV_PARAM_idm10941.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/base.hpp>
+
+BOOST_CNV_PARAM(param_name, param_type)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_PARAM_idm10945.html b/doc/html/BOOST_CNV_PARAM_idm10945.html new file mode 100644 index 0000000..048c838 --- /dev/null +++ b/doc/html/BOOST_CNV_PARAM_idm10945.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/base.hpp>
+
+BOOST_CNV_PARAM(param_name, param_type)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_PARAM_idm10967.html b/doc/html/BOOST_CNV_PARAM_idm10967.html new file mode 100644 index 0000000..04d299c --- /dev/null +++ b/doc/html/BOOST_CNV_PARAM_idm10967.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/base.hpp>
+
+BOOST_CNV_PARAM(param_name, param_type)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_PARAM_idm11238.html b/doc/html/BOOST_CNV_PARAM_idm11238.html new file mode 100644 index 0000000..c971358 --- /dev/null +++ b/doc/html/BOOST_CNV_PARAM_idm11238.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+BOOST_CNV_PARAM(PARAM_NAME, PARAM_TYPE)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_PARAM_idm11240.html b/doc/html/BOOST_CNV_PARAM_idm11240.html new file mode 100644 index 0000000..4c234fe --- /dev/null +++ b/doc/html/BOOST_CNV_PARAM_idm11240.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+BOOST_CNV_PARAM(PARAM_NAME, PARAM_TYPE)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_PARAM_idm11244.html b/doc/html/BOOST_CNV_PARAM_idm11244.html new file mode 100644 index 0000000..1e9fe35 --- /dev/null +++ b/doc/html/BOOST_CNV_PARAM_idm11244.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+BOOST_CNV_PARAM(PARAM_NAME, PARAM_TYPE)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_PARAM_idm11266.html b/doc/html/BOOST_CNV_PARAM_idm11266.html new file mode 100644 index 0000000..e642ef2 --- /dev/null +++ b/doc/html/BOOST_CNV_PARAM_idm11266.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+BOOST_CNV_PARAM(PARAM_NAME, PARAM_TYPE)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_STRING_ENABLE.html b/doc/html/BOOST_CNV_STRING_ENABLE.html new file mode 100644 index 0000000..8ca3e38 --- /dev/null +++ b/doc/html/BOOST_CNV_STRING_ENABLE.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_STRING_ENABLE + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_STRING_ENABLE

+

BOOST_CNV_STRING_ENABLE

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+BOOST_CNV_STRING_ENABLE
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_STRING_TO.html b/doc/html/BOOST_CNV_STRING_TO.html new file mode 100644 index 0000000..b98b3d0 --- /dev/null +++ b/doc/html/BOOST_CNV_STRING_TO.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_STRING_TO + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_STRING_TO

+

BOOST_CNV_STRING_TO

+
+

Synopsis

+
// In header: <boost/convert/base.hpp>
+
+BOOST_CNV_STRING_TO
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CNV_TO_STRING.html b/doc/html/BOOST_CNV_TO_STRING.html new file mode 100644 index 0000000..cf81686 --- /dev/null +++ b/doc/html/BOOST_CNV_TO_STRING.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_TO_STRING + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_TO_STRING

+

BOOST_CNV_TO_STRING

+
+

Synopsis

+
// In header: <boost/convert/base.hpp>
+
+BOOST_CNV_TO_STRING
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CN_idm46323349411056.html b/doc/html/BOOST_CN_idm46323349411056.html new file mode 100644 index 0000000..d7a6f4d --- /dev/null +++ b/doc/html/BOOST_CN_idm46323349411056.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+BOOST_CNV_PARAM(PARAM_NAME, PARAM_TYPE)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/BOOST_CN_idm46323349539088.html b/doc/html/BOOST_CN_idm46323349539088.html new file mode 100644 index 0000000..5fc1605 --- /dev/null +++ b/doc/html/BOOST_CN_idm46323349539088.html @@ -0,0 +1,48 @@ + + + +Macro BOOST_CNV_PARAM + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Macro BOOST_CNV_PARAM

+

BOOST_CNV_PARAM

+
+

Synopsis

+
// In header: <boost/convert/base.hpp>
+
+BOOST_CNV_PARAM(param_name, param_type)
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/apply_idm10601.html b/doc/html/boost/cnv/apply_idm10601.html new file mode 100644 index 0000000..7699a0d --- /dev/null +++ b/doc/html/boost/cnv/apply_idm10601.html @@ -0,0 +1,67 @@ + + + +Function template apply + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template apply

+

boost::cnv::apply — Boost.Convert deployment interface with algorithms.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  reference< Converter, TypeOut, TypeIn > apply(Converter const & cnv);
+
+

Description

+

For example,

+
boost::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>             ints;
+boost::cnv::cstream           cnv;
+
+cnv(std::hex)(std::skipws);
+
+std::transform(
+    strs.begin(),
+    strs.end(),
+    std::back_inserter(ints),
+    boost::cnv::apply<int>(boost::cref(cnv)).value_or(-1));
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/apply_idm10603.html b/doc/html/boost/cnv/apply_idm10603.html new file mode 100644 index 0000000..d94266b --- /dev/null +++ b/doc/html/boost/cnv/apply_idm10603.html @@ -0,0 +1,67 @@ + + + +Function template apply + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template apply

+

boost::cnv::apply — Boost.Convert deployment interface with algorithms.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  reference< Converter, TypeOut, TypeIn > apply(Converter const & cnv);
+
+

Description

+

For example,

+
boost::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>             ints;
+boost::cnv::cstream           cnv;
+
+cnv(std::hex)(std::skipws);
+
+std::transform(
+    strs.begin(),
+    strs.end(),
+    std::back_inserter(ints),
+    boost::cnv::apply<int>(boost::cref(cnv)).value_or(-1));
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/apply_idm10607.html b/doc/html/boost/cnv/apply_idm10607.html new file mode 100644 index 0000000..0951c76 --- /dev/null +++ b/doc/html/boost/cnv/apply_idm10607.html @@ -0,0 +1,67 @@ + + + +Function template apply + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template apply

+

boost::cnv::apply — Boost.Convert deployment interface with algorithms.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  reference< Converter, TypeOut, TypeIn > apply(Converter const & cnv);
+
+

Description

+

For example,

+
boost::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>             ints;
+boost::cnv::cstream           cnv;
+
+cnv(std::hex)(std::skipws);
+
+std::transform(
+    strs.begin(),
+    strs.end(),
+    std::back_inserter(ints),
+    boost::cnv::apply<int>(boost::cref(cnv)).value_or(-1));
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/apply_idm10629.html b/doc/html/boost/cnv/apply_idm10629.html new file mode 100644 index 0000000..3132b29 --- /dev/null +++ b/doc/html/boost/cnv/apply_idm10629.html @@ -0,0 +1,67 @@ + + + +Function template apply + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template apply

+

boost::cnv::apply — Boost.Convert deployment interface with algorithms.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  reference< Converter, TypeOut, TypeIn > apply(Converter const & cnv);
+
+

Description

+

For example,

+
boost::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>             ints;
+boost::cnv::cstream           cnv;
+
+cnv(std::hex)(std::skipws);
+
+std::transform(
+    strs.begin(),
+    strs.end(),
+    std::back_inserter(ints),
+    boost::cnv::apply<int>(boost::cref(cnv)).value_or(-1));
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/apply_idm46323361464960.html b/doc/html/boost/cnv/apply_idm46323361464960.html new file mode 100644 index 0000000..b286933 --- /dev/null +++ b/doc/html/boost/cnv/apply_idm46323361464960.html @@ -0,0 +1,67 @@ + + + +Function template apply + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template apply

+

boost::cnv::apply — Boost.Convert deployment interface with algorithms.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  reference< Converter, TypeOut, TypeIn > apply(Converter const & cnv);
+
+

Description

+

For example,

+
boost::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>             ints;
+boost::cnv::cstream           cnv;
+
+cnv(std::hex)(std::skipws);
+
+std::transform(
+    strs.begin(),
+    strs.end(),
+    std::back_inserter(ints),
+    boost::cnv::apply<int>(boost::cref(cnv)).value_or(-1));
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/basic_stream.html b/doc/html/boost/cnv/basic_stream.html new file mode 100644 index 0000000..581a513 --- /dev/null +++ b/doc/html/boost/cnv/basic_stream.html @@ -0,0 +1,156 @@ + + + +Struct template basic_stream + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct template basic_stream

+

boost::cnv::basic_stream

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+template<typename Char> 
+struct basic_stream {
+  // types
+  typedef Char                                  char_type;       
+  typedef boost::cnv::basic_stream< char_type > this_type;       
+  typedef std::basic_stringstream< char_type >  stream_type;     
+  typedef std::basic_istream< char_type >       istream_type;    
+  typedef std::basic_streambuf< char_type >     buffer_type;     
+  typedef std::basic_string< char_type >        stdstr_type;     
+  typedef std::ios_base &(*)(std::ios_base &)   manipulator_type;
+
+  // member classes/structs/unions
+
+  struct ibuffer_type : public buffer_type {
+    // construct/copy/destruct
+    ibuffer_type(char_type const *, std::size_t);
+  };
+
+  struct obuffer_type : public buffer_type {
+  };
+
+  // construct/copy/destruct
+  basic_stream();
+  basic_stream(this_type &&);
+
+  // public member functions
+   BOOST_CNV_STRING_ENABLE(type const &, optional< string_type > &) const;
+   BOOST_CNV_STRING_ENABLE(string_type const &, optional< type > &) const;
+  template<typename type> 
+    void operator()(char_type const *, optional< type > &) const;
+  template<typename type> 
+    void operator()(stdstr_type const &, optional< type > &) const;
+  template<typename manipulator> this_type & operator()(manipulator);
+  this_type & operator()(manipulator_type);
+  this_type & operator()(std::locale const &);
+   BOOST_CNV_PARAM(locale, std::locale);
+   BOOST_CNV_PARAM(precision, int);
+   BOOST_CNV_PARAM(width, int);
+   BOOST_CNV_PARAM(fill, char);
+   BOOST_CNV_PARAM(uppercase, bool);
+   BOOST_CNV_PARAM(skipws, bool);
+   BOOST_CNV_PARAM(adjust, boost::cnv::adjust);
+   BOOST_CNV_PARAM(base, boost::cnv::base);
+   BOOST_CNV_PARAM(notation, boost::cnv::notation);
+  template<typename string_type, typename in_type> 
+    void to_str(in_type const &, boost::optional< string_type > &) const;
+  template<typename string_type, typename out_type> 
+    void str_to(boost::cnv::range< string_type >, 
+                boost::optional< out_type > &) const;
+
+  // private member functions
+  template<typename string_type, typename out_type> 
+    void str_to(cnv::range< string_type >, optional< out_type > &) const;
+  template<typename string_type, typename in_type> 
+    void to_str(in_type const &, optional< string_type > &) const;
+};
+
+

Description

+
+

+basic_stream + public + construct/copy/destruct

+
    +
  1. basic_stream();
  2. +
  3. basic_stream(this_type && other);
  4. +
+
+
+

+basic_stream public member functions

+
    +
  1.  BOOST_CNV_STRING_ENABLE(type const & v, optional< string_type > & s) const;
  2. +
  3.  BOOST_CNV_STRING_ENABLE(string_type const & s, optional< type > & r) const;
  4. +
  5. template<typename type> 
    +  void operator()(char_type const * s, optional< type > & r) const;
  6. +
  7. template<typename type> 
    +  void operator()(stdstr_type const & s, optional< type > & r) const;
  8. +
  9. template<typename manipulator> this_type & operator()(manipulator m);
  10. +
  11. this_type & operator()(manipulator_type m);
  12. +
  13. this_type & operator()(std::locale const & l);
  14. +
  15.  BOOST_CNV_PARAM(locale, std::locale);
  16. +
  17.  BOOST_CNV_PARAM(precision, int);
  18. +
  19.  BOOST_CNV_PARAM(width, int);
  20. +
  21.  BOOST_CNV_PARAM(fill, char);
  22. +
  23.  BOOST_CNV_PARAM(uppercase, bool);
  24. +
  25.  BOOST_CNV_PARAM(skipws, bool);
  26. +
  27.  BOOST_CNV_PARAM(adjust, boost::cnv::adjust);
  28. +
  29.  BOOST_CNV_PARAM(base, boost::cnv::base);
  30. +
  31.  BOOST_CNV_PARAM(notation, boost::cnv::notation);
  32. +
  33. template<typename string_type, typename in_type> 
    +  void to_str(in_type const & value_in, 
    +              boost::optional< string_type > & string_out) const;
  34. +
  35. template<typename string_type, typename out_type> 
    +  void str_to(boost::cnv::range< string_type > string_in, 
    +              boost::optional< out_type > & result_out) const;
  36. +
+
+
+

+basic_stream private member functions

+
    +
  1. template<typename string_type, typename out_type> 
    +  void str_to(cnv::range< string_type >, optional< out_type > &) const;
  2. +
  3. template<typename string_type, typename in_type> 
    +  void to_str(in_type const &, optional< string_type > &) const;
  4. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/basic_stream/ibuffer_type.html b/doc/html/boost/cnv/basic_stream/ibuffer_type.html new file mode 100644 index 0000000..21f6572 --- /dev/null +++ b/doc/html/boost/cnv/basic_stream/ibuffer_type.html @@ -0,0 +1,63 @@ + + + +Struct ibuffer_type + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct ibuffer_type

+

boost::cnv::basic_stream::ibuffer_type

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+
+
+struct ibuffer_type : public buffer_type {
+  // construct/copy/destruct
+  ibuffer_type(char_type const *, std::size_t);
+};
+
+

Description

+
+

+ibuffer_type + public + construct/copy/destruct

+
  1. ibuffer_type(char_type const * beg, std::size_t sz);
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/basic_stream/obuffer_type.html b/doc/html/boost/cnv/basic_stream/obuffer_type.html new file mode 100644 index 0000000..05e41cd --- /dev/null +++ b/doc/html/boost/cnv/basic_stream/obuffer_type.html @@ -0,0 +1,51 @@ + + + +Struct obuffer_type + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct obuffer_type

+

boost::cnv::basic_stream::obuffer_type

+
+

Synopsis

+
// In header: <boost/convert/stream.hpp>
+
+
+
+struct obuffer_type : public buffer_type {
+};
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/cnvbase.html b/doc/html/boost/cnv/cnvbase.html new file mode 100644 index 0000000..b675eff --- /dev/null +++ b/doc/html/boost/cnv/cnvbase.html @@ -0,0 +1,166 @@ + + + +Struct template cnvbase + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct template cnvbase

+

boost::cnv::cnvbase

+
+

Synopsis

+
// In header: <boost/convert/base.hpp>
+
+template<typename derived_type> 
+struct cnvbase {
+  // types
+  typedef cnvbase                this_type;  
+  typedef int                    int_type;   
+  typedef unsigned int           uint_type;  
+  typedef long int               lint_type;  
+  typedef unsigned long int      ulint_type; 
+  typedef short int              sint_type;  
+  typedef unsigned short int     usint_type; 
+  typedef long long int          llint_type; 
+  typedef unsigned long long int ullint_type;
+  typedef float                  flt_type;   
+  typedef double                 dbl_type;   
+  typedef long double            ldbl_type;  
+
+  // construct/copy/destruct
+  cnvbase();
+
+  // public member functions
+  template<typename type_in, typename type_out> 
+    void operator()(type_in const &, boost::optional< type_out > &) const;
+   BOOST_CNV_TO_STRING(int_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(uint_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(lint_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(llint_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(ulint_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(ullint_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(sint_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(usint_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(flt_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(dbl_type, optional< string_type > &) const;
+   BOOST_CNV_TO_STRING(ldbl_type, optional< string_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< int_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< uint_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< lint_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< llint_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< ulint_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< ullint_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< sint_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< usint_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< flt_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< dbl_type > &) const;
+   BOOST_CNV_STRING_TO(string_type const &, optional< ldbl_type > &) const;
+   BOOST_CNV_PARAM(base, cnv::base);
+   BOOST_CNV_PARAM(adjust, cnv::adjust);
+   BOOST_CNV_PARAM(precision, int);
+   BOOST_CNV_PARAM(uppercase, bool);
+   BOOST_CNV_PARAM(skipws, bool);
+   BOOST_CNV_PARAM(width, int);
+   BOOST_CNV_PARAM(fill, char);
+
+  // protected member functions
+  template<typename string_type, typename out_type> 
+    void str_to_(string_type const &, optional< out_type > &) const;
+  template<typename in_type, typename string_type> 
+    void to_str_(in_type, optional< string_type > &) const;
+  derived_type const  & dncast() const;
+  derived_type & dncast();
+};
+
+

Description

+
+

+cnvbase + public + construct/copy/destruct

+
  1. cnvbase();
+
+
+

+cnvbase public member functions

+
    +
  1. template<typename type_in, typename type_out> 
    +  void operator()(type_in const & in, boost::optional< type_out > & out) const;
  2. +
  3.  BOOST_CNV_TO_STRING(int_type v, optional< string_type > & r) const;
  4. +
  5.  BOOST_CNV_TO_STRING(uint_type v, optional< string_type > & r) const;
  6. +
  7.  BOOST_CNV_TO_STRING(lint_type v, optional< string_type > & r) const;
  8. +
  9.  BOOST_CNV_TO_STRING(llint_type v, optional< string_type > & r) const;
  10. +
  11.  BOOST_CNV_TO_STRING(ulint_type v, optional< string_type > & r) const;
  12. +
  13.  BOOST_CNV_TO_STRING(ullint_type v, optional< string_type > & r) const;
  14. +
  15.  BOOST_CNV_TO_STRING(sint_type v, optional< string_type > & r) const;
  16. +
  17.  BOOST_CNV_TO_STRING(usint_type v, optional< string_type > & r) const;
  18. +
  19.  BOOST_CNV_TO_STRING(flt_type v, optional< string_type > & r) const;
  20. +
  21.  BOOST_CNV_TO_STRING(dbl_type v, optional< string_type > & r) const;
  22. +
  23.  BOOST_CNV_TO_STRING(ldbl_type v, optional< string_type > & r) const;
  24. +
  25.  BOOST_CNV_STRING_TO(string_type const & s, optional< int_type > & r) const;
  26. +
  27.  BOOST_CNV_STRING_TO(string_type const & s, optional< uint_type > & r) const;
  28. +
  29.  BOOST_CNV_STRING_TO(string_type const & s, optional< lint_type > & r) const;
  30. +
  31.  BOOST_CNV_STRING_TO(string_type const & s, optional< llint_type > & r) const;
  32. +
  33.  BOOST_CNV_STRING_TO(string_type const & s, optional< ulint_type > & r) const;
  34. +
  35.  BOOST_CNV_STRING_TO(string_type const & s, optional< ullint_type > & r) const;
  36. +
  37.  BOOST_CNV_STRING_TO(string_type const & s, optional< sint_type > & r) const;
  38. +
  39.  BOOST_CNV_STRING_TO(string_type const & s, optional< usint_type > & r) const;
  40. +
  41.  BOOST_CNV_STRING_TO(string_type const & s, optional< flt_type > & r) const;
  42. +
  43.  BOOST_CNV_STRING_TO(string_type const & s, optional< dbl_type > & r) const;
  44. +
  45.  BOOST_CNV_STRING_TO(string_type const & s, optional< ldbl_type > & r) const;
  46. +
  47.  BOOST_CNV_PARAM(base, cnv::base);
  48. +
  49.  BOOST_CNV_PARAM(adjust, cnv::adjust);
  50. +
  51.  BOOST_CNV_PARAM(precision, int);
  52. +
  53.  BOOST_CNV_PARAM(uppercase, bool);
  54. +
  55.  BOOST_CNV_PARAM(skipws, bool);
  56. +
  57.  BOOST_CNV_PARAM(width, int);
  58. +
  59.  BOOST_CNV_PARAM(fill, char);
  60. +
+
+
+

+cnvbase protected member functions

+
    +
  1. template<typename string_type, typename out_type> 
    +  void str_to_(string_type const & str, optional< out_type > & result_out) const;
  2. +
  3. template<typename in_type, typename string_type> 
    +  void to_str_(in_type value_in, optional< string_type > & result_out) const;
  4. +
  5. derived_type const  & dncast() const;
  6. +
  7. derived_type & dncast();
  8. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/lexical_cast.html b/doc/html/boost/cnv/lexical_cast.html new file mode 100644 index 0000000..466738e --- /dev/null +++ b/doc/html/boost/cnv/lexical_cast.html @@ -0,0 +1,71 @@ + + + +Struct lexical_cast + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct lexical_cast

+

boost::cnv::lexical_cast — boost::lexical_cast-based converter

+
+

Synopsis

+
// In header: <boost/convert/lexical_cast.hpp>
+
+
+struct lexical_cast {
+
+  // public member functions
+  template<typename TypeOut, typename TypeIn> 
+    void operator()(TypeIn const &, boost::optional< TypeOut > &) const;
+};
+
+

Description

+

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 The converter can easily replace boost::lexical_cast, adding flexibility and convenience.

  • +
+

+

+
+

+lexical_cast public member functions

+
  1. template<typename TypeOut, typename TypeIn> 
    +  void operator()(TypeIn const & value_in, 
    +                  boost::optional< TypeOut > & result_out) const;
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/printf.html b/doc/html/boost/cnv/printf.html new file mode 100644 index 0000000..42625b2 --- /dev/null +++ b/doc/html/boost/cnv/printf.html @@ -0,0 +1,87 @@ + + + +Struct printf + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct printf

+

boost::cnv::printf

+
+

Synopsis

+
// In header: <boost/convert/printf.hpp>
+
+
+struct printf : public boost::cnv::cnvbase< boost::cnv::printf > {
+  // types
+  typedef boost::cnv::printf               this_type;
+  typedef boost::cnv::cnvbase< this_type > base_type;
+
+  // public member functions
+  template<typename in_type> 
+    cnv::range< char * > to_str(in_type, char *) const;
+  template<typename string_type, typename out_type> 
+    void str_to(cnv::range< string_type >, optional< out_type > &) const;
+
+  // private member functions
+  template<typename Type> int pos() const;
+  char const  * pformat(int) const;
+  char const  * format(int) const;
+};
+
+

Description

+
+

+printf public member functions

+
    +
  1. template<typename in_type> 
    +  cnv::range< char * > to_str(in_type value_in, char * buf) const;
  2. +
  3. template<typename string_type, typename out_type> 
    +  void str_to(cnv::range< string_type > range, 
    +              optional< out_type > & result_out) const;
  4. +
+
+
+

+printf private member functions

+
    +
  1. template<typename Type> int pos() const;
  2. +
  3. char const  * pformat(int pos) const;
  4. +
  5. char const  * format(int pos) const;
  6. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/referenc_idm46323361474640.html b/doc/html/boost/cnv/referenc_idm46323361474640.html new file mode 100644 index 0000000..e81c5c4 --- /dev/null +++ b/doc/html/boost/cnv/referenc_idm46323361474640.html @@ -0,0 +1,77 @@ + + + +Struct template reference<Converter, TypeOut, void> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct template reference<Converter, TypeOut, void>

+

boost::cnv::reference<Converter, TypeOut, void>

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+template<typename Converter, typename TypeOut> 
+struct reference<Converter, TypeOut, void> {
+  // types
+  typedef reference this_type;
+
+  // construct/copy/destruct
+  reference(Converter const &);
+
+  // public member functions
+  this_type & value_or(TypeOut const &);
+  template<typename TypeIn> TypeOut operator()(TypeIn const &);
+};
+
+

Description

+
+

+reference + public + construct/copy/destruct

+
  1. reference(Converter const & cnv);
+
+
+

+reference public member functions

+
    +
  1. this_type & value_or(TypeOut const & fallback);
  2. +
  3. template<typename TypeIn> TypeOut operator()(TypeIn const & value_in);
  4. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/reference.html b/doc/html/boost/cnv/reference.html new file mode 100644 index 0000000..9ba223a --- /dev/null +++ b/doc/html/boost/cnv/reference.html @@ -0,0 +1,77 @@ + + + +Struct template reference + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct template reference

+

boost::cnv::reference

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+template<typename Converter, typename TypeOut, typename TypeIn> 
+struct reference {
+  // types
+  typedef reference this_type;
+
+  // construct/copy/destruct
+  reference(Converter const &);
+
+  // public member functions
+  this_type & value_or(TypeOut const &);
+  TypeOut operator()(TypeIn const &);
+};
+
+

Description

+
+

+reference + public + construct/copy/destruct

+
  1. reference(Converter const & cnv);
+
+
+

+reference public member functions

+
    +
  1. this_type & value_or(TypeOut const & fallback);
  2. +
  3. TypeOut operator()(TypeIn const & value_in);
  4. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/reference_Convert_idm10575.html b/doc/html/boost/cnv/reference_Convert_idm10575.html new file mode 100644 index 0000000..7b86676 --- /dev/null +++ b/doc/html/boost/cnv/reference_Convert_idm10575.html @@ -0,0 +1,77 @@ + + + +Struct template reference<Converter, TypeOut, void> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct template reference<Converter, TypeOut, void>

+

boost::cnv::reference<Converter, TypeOut, void>

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+template<typename Converter, typename TypeOut> 
+struct reference<Converter, TypeOut, void> {
+  // types
+  typedef reference this_type;
+
+  // construct/copy/destruct
+  reference(Converter const &);
+
+  // public member functions
+  this_type & value_or(TypeOut const &);
+  template<typename TypeIn> TypeOut operator()(TypeIn const &);
+};
+
+

Description

+
+

+reference + public + construct/copy/destruct

+
  1. reference(Converter const & cnv);
+
+
+

+reference public member functions

+
    +
  1. this_type & value_or(TypeOut const & fallback);
  2. +
  3. template<typename TypeIn> TypeOut operator()(TypeIn const & value_in);
  4. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/reference_Convert_idm10577.html b/doc/html/boost/cnv/reference_Convert_idm10577.html new file mode 100644 index 0000000..1f8d8ff --- /dev/null +++ b/doc/html/boost/cnv/reference_Convert_idm10577.html @@ -0,0 +1,77 @@ + + + +Struct template reference<Converter, TypeOut, void> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct template reference<Converter, TypeOut, void>

+

boost::cnv::reference<Converter, TypeOut, void>

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+template<typename Converter, typename TypeOut> 
+struct reference<Converter, TypeOut, void> {
+  // types
+  typedef reference this_type;
+
+  // construct/copy/destruct
+  reference(Converter const &);
+
+  // public member functions
+  this_type & value_or(TypeOut const &);
+  template<typename TypeIn> TypeOut operator()(TypeIn const &);
+};
+
+

Description

+
+

+reference + public + construct/copy/destruct

+
  1. reference(Converter const & cnv);
+
+
+

+reference public member functions

+
    +
  1. this_type & value_or(TypeOut const & fallback);
  2. +
  3. template<typename TypeIn> TypeOut operator()(TypeIn const & value_in);
  4. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/reference_Convert_idm10581.html b/doc/html/boost/cnv/reference_Convert_idm10581.html new file mode 100644 index 0000000..fe4f68d --- /dev/null +++ b/doc/html/boost/cnv/reference_Convert_idm10581.html @@ -0,0 +1,77 @@ + + + +Struct template reference<Converter, TypeOut, void> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct template reference<Converter, TypeOut, void>

+

boost::cnv::reference<Converter, TypeOut, void>

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+template<typename Converter, typename TypeOut> 
+struct reference<Converter, TypeOut, void> {
+  // types
+  typedef reference this_type;
+
+  // construct/copy/destruct
+  reference(Converter const &);
+
+  // public member functions
+  this_type & value_or(TypeOut const &);
+  template<typename TypeIn> TypeOut operator()(TypeIn const &);
+};
+
+

Description

+
+

+reference + public + construct/copy/destruct

+
  1. reference(Converter const & cnv);
+
+
+

+reference public member functions

+
    +
  1. this_type & value_or(TypeOut const & fallback);
  2. +
  3. template<typename TypeIn> TypeOut operator()(TypeIn const & value_in);
  4. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/reference_Convert_idm10603.html b/doc/html/boost/cnv/reference_Convert_idm10603.html new file mode 100644 index 0000000..82e6912 --- /dev/null +++ b/doc/html/boost/cnv/reference_Convert_idm10603.html @@ -0,0 +1,77 @@ + + + +Struct template reference<Converter, TypeOut, void> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct template reference<Converter, TypeOut, void>

+

boost::cnv::reference<Converter, TypeOut, void>

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+template<typename Converter, typename TypeOut> 
+struct reference<Converter, TypeOut, void> {
+  // types
+  typedef reference this_type;
+
+  // construct/copy/destruct
+  reference(Converter const &);
+
+  // public member functions
+  this_type & value_or(TypeOut const &);
+  template<typename TypeIn> TypeOut operator()(TypeIn const &);
+};
+
+

Description

+
+

+reference + public + construct/copy/destruct

+
  1. reference(Converter const & cnv);
+
+
+

+reference public member functions

+
    +
  1. this_type & value_or(TypeOut const & fallback);
  2. +
  3. template<typename TypeIn> TypeOut operator()(TypeIn const & value_in);
  4. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/spirit.html b/doc/html/boost/cnv/spirit.html new file mode 100644 index 0000000..f01d433 --- /dev/null +++ b/doc/html/boost/cnv/spirit.html @@ -0,0 +1,73 @@ + + + +Struct spirit + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct spirit

+

boost::cnv::spirit

+
+

Synopsis

+
// In header: <boost/convert/spirit.hpp>
+
+
+struct spirit : public boost::cnv::cnvbase< boost::cnv::spirit > {
+  // types
+  typedef boost::cnv::spirit               this_type;
+  typedef boost::cnv::cnvbase< this_type > base_type;
+
+  // public member functions
+  template<typename string_type, typename out_type> 
+    void str_to(cnv::range< string_type >, optional< out_type > &) const;
+  template<typename in_type, typename char_type> 
+    cnv::range< char_type * > to_str(in_type, char_type *) const;
+};
+
+

Description

+
+

+spirit public member functions

+
    +
  1. template<typename string_type, typename out_type> 
    +  void str_to(cnv::range< string_type > range, 
    +              optional< out_type > & result_out) const;
  2. +
  3. template<typename in_type, typename char_type> 
    +  cnv::range< char_type * > to_str(in_type value_in, char_type * beg) const;
  4. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/cnv/strtol.html b/doc/html/boost/cnv/strtol.html new file mode 100644 index 0000000..1751e0e --- /dev/null +++ b/doc/html/boost/cnv/strtol.html @@ -0,0 +1,183 @@ + + + +Struct strtol + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Struct strtol

+

boost::cnv::strtol — std::strtol-based extended converter

+
+

Synopsis

+
// In header: <boost/convert/strtol.hpp>
+
+
+struct strtol : public boost::cnv::cnvbase< boost::cnv::strtol > {
+  // types
+  typedef boost::cnv::strtol               this_type;
+  typedef boost::cnv::cnvbase< this_type > base_type;
+
+  // private member functions
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< int_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< sint_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< lint_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< llint_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< uint_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< usint_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< ulint_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< ullint_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< flt_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< dbl_type > &) const;
+  template<typename string_type> 
+    void str_to(cnv::range< string_type >, optional< ldbl_type > &) const;
+  template<typename char_type> 
+    cnv::range< char_type * > to_str(int_type, char_type *) const;
+  template<typename char_type> 
+    cnv::range< char_type * > to_str(uint_type, char_type *) const;
+  template<typename char_type> 
+    cnv::range< char_type * > to_str(lint_type, char_type *) const;
+  template<typename char_type> 
+    cnv::range< char_type * > to_str(ulint_type, char_type *) const;
+  template<typename char_type> 
+    cnv::range< char_type * > to_str(llint_type, char_type *) const;
+  template<typename char_type> 
+    cnv::range< char_type * > to_str(ullint_type, char_type *) const;
+  template<typename char_type> 
+    cnv::range< char_type * > to_str(dbl_type, char_type *) const;
+  template<typename char_type, typename in_type> 
+    cnv::range< char_type * > i_to_str(in_type, char_type *) const;
+  template<typename string_type, typename out_type> 
+    void str_to_i(cnv::range< string_type >, optional< out_type > &) const;
+  template<typename string_type, typename out_type> 
+    void str_to_d(cnv::range< string_type >, optional< out_type > &) const;
+
+  // private static functions
+  static double adjust_fraction(double, int);
+  static int get_char(int);
+
+  // public member functions
+  template<typename char_type, typename Type> 
+    boost::cnv::range< char_type * > i_to_str(Type, char_type *) const;
+  template<typename char_type> 
+    boost::cnv::range< char_type * > to_str(double, char_type *) const;
+  template<typename string_type, typename out_type> 
+    void str_to_i(cnv::range< string_type >, boost::optional< out_type > &) const;
+};
+
+

Description

+

The converter offers a fairly decent overall performance and moderate formatting facilities.

+
+

+strtol private member functions

+
    +
  1. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< int_type > & r) const;
  2. +
  3. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< sint_type > & r) const;
  4. +
  5. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< lint_type > & r) const;
  6. +
  7. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< llint_type > & r) const;
  8. +
  9. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< uint_type > & r) const;
  10. +
  11. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< usint_type > & r) const;
  12. +
  13. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< ulint_type > & r) const;
  14. +
  15. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< ullint_type > & r) const;
  16. +
  17. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< flt_type > & r) const;
  18. +
  19. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< dbl_type > & r) const;
  20. +
  21. template<typename string_type> 
    +  void str_to(cnv::range< string_type > v, optional< ldbl_type > & r) const;
  22. +
  23. template<typename char_type> 
    +  cnv::range< char_type * > to_str(int_type v, char_type * buf) const;
  24. +
  25. template<typename char_type> 
    +  cnv::range< char_type * > to_str(uint_type v, char_type * buf) const;
  26. +
  27. template<typename char_type> 
    +  cnv::range< char_type * > to_str(lint_type v, char_type * buf) const;
  28. +
  29. template<typename char_type> 
    +  cnv::range< char_type * > to_str(ulint_type v, char_type * buf) const;
  30. +
  31. template<typename char_type> 
    +  cnv::range< char_type * > to_str(llint_type v, char_type * buf) const;
  32. +
  33. template<typename char_type> 
    +  cnv::range< char_type * > to_str(ullint_type v, char_type * buf) const;
  34. +
  35. template<typename char_type> 
    +  cnv::range< char_type * > to_str(dbl_type v, char_type * buf) const;
  36. +
  37. template<typename char_type, typename in_type> 
    +  cnv::range< char_type * > i_to_str(in_type, char_type *) const;
  38. +
  39. template<typename string_type, typename out_type> 
    +  void str_to_i(cnv::range< string_type >, optional< out_type > &) const;
  40. +
  41. template<typename string_type, typename out_type> 
    +  void str_to_d(cnv::range< string_type >, optional< out_type > &) const;
  42. +
+
+
+

+strtol private static functions

+
    +
  1. static double adjust_fraction(double, int);
  2. +
  3. static int get_char(int v);
  4. +
+
+
+

+strtol public member functions

+
    +
  1. template<typename char_type, typename Type> 
    +  boost::cnv::range< char_type * > 
    +  i_to_str(Type in_value, char_type * buf) const;
  2. +
  3. template<typename char_type> 
    +  boost::cnv::range< char_type * > to_str(double value, char_type * buf) const;
  4. +
  5. template<typename string_type, typename out_type> 
    +  void str_to_i(cnv::range< string_type > range, 
    +                boost::optional< out_type > & result_out) const;
  6. +
+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm10627.html b/doc/html/boost/convert_idm10627.html new file mode 100644 index 0000000..43cad1a --- /dev/null +++ b/doc/html/boost/convert_idm10627.html @@ -0,0 +1,94 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert main deployment interface.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  boost::optional< TypeOut > 
+  convert(TypeIn const & value_in, Converter const & converter);
+
+

Description

+

+ +For example,

+
boost::cnv::cstream cnv;
+
+boost::optional<int>    i = boost::convert<int>("12", cnv);
+boost::optional<string> s = boost::convert<string>(123.456, cnv);
+
+

+
++++ + + + + + + + + + + +

Parameters:

++++ + + + + + + + + + + +

converter

Converter to be used for conversion

value_in

Value of the TypeIn type to be converted to the TypeOut type

Returns:

boost::optional<TypeOut> result of conversion together with the indication of success or failure of the conversion request.

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm10629.html b/doc/html/boost/convert_idm10629.html new file mode 100644 index 0000000..07ac4b1 --- /dev/null +++ b/doc/html/boost/convert_idm10629.html @@ -0,0 +1,94 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert main deployment interface.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  boost::optional< TypeOut > 
+  convert(TypeIn const & value_in, Converter const & converter);
+
+

Description

+

+ +For example,

+
boost::cnv::cstream cnv;
+
+boost::optional<int>    i = boost::convert<int>("12", cnv);
+boost::optional<string> s = boost::convert<string>(123.456, cnv);
+
+

+
++++ + + + + + + + + + + +

Parameters:

++++ + + + + + + + + + + +

converter

Converter to be used for conversion

value_in

Value of the TypeIn type to be converted to the TypeOut type

Returns:

boost::optional<TypeOut> result of conversion together with the indication of success or failure of the conversion request.

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm10633.html b/doc/html/boost/convert_idm10633.html new file mode 100644 index 0000000..99ce97e --- /dev/null +++ b/doc/html/boost/convert_idm10633.html @@ -0,0 +1,94 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert main deployment interface.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  boost::optional< TypeOut > 
+  convert(TypeIn const & value_in, Converter const & converter);
+
+

Description

+

+ +For example,

+
boost::cnv::cstream cnv;
+
+boost::optional<int>    i = boost::convert<int>("12", cnv);
+boost::optional<string> s = boost::convert<string>(123.456, cnv);
+
+

+
++++ + + + + + + + + + + +

Parameters:

++++ + + + + + + + + + + +

converter

Converter to be used for conversion

value_in

Value of the TypeIn type to be converted to the TypeOut type

Returns:

boost::optional<TypeOut> result of conversion together with the indication of success or failure of the conversion request.

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm10647.html b/doc/html/boost/convert_idm10647.html new file mode 100644 index 0000000..5c2013f --- /dev/null +++ b/doc/html/boost/convert_idm10647.html @@ -0,0 +1,62 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert deployment interface with the default converter.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn> 
+  boost::optional< TypeOut > convert(TypeIn const & value_in);
+
+

Description

+

For example,

+
struct boost::cnv::by_default : boost::cnv::cstream {};
+
+// boost::cnv::cstream (through boost::cnv::by_default) is deployed
+// as the default converter when no converter is provided explicitly.
+boost::optional<int>    i = boost::convert<int>("12");
+boost::optional<string> s = boost::convert<string>(123.456);
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm10649.html b/doc/html/boost/convert_idm10649.html new file mode 100644 index 0000000..e92a001 --- /dev/null +++ b/doc/html/boost/convert_idm10649.html @@ -0,0 +1,62 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert deployment interface with the default converter.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn> 
+  boost::optional< TypeOut > convert(TypeIn const & value_in);
+
+

Description

+

For example,

+
struct boost::cnv::by_default : boost::cnv::cstream {};
+
+// boost::cnv::cstream (through boost::cnv::by_default) is deployed
+// as the default converter when no converter is provided explicitly.
+boost::optional<int>    i = boost::convert<int>("12");
+boost::optional<string> s = boost::convert<string>(123.456);
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm10653.html b/doc/html/boost/convert_idm10653.html new file mode 100644 index 0000000..a48113c --- /dev/null +++ b/doc/html/boost/convert_idm10653.html @@ -0,0 +1,62 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert deployment interface with the default converter.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn> 
+  boost::optional< TypeOut > convert(TypeIn const & value_in);
+
+

Description

+

For example,

+
struct boost::cnv::by_default : boost::cnv::cstream {};
+
+// boost::cnv::cstream (through boost::cnv::by_default) is deployed
+// as the default converter when no converter is provided explicitly.
+boost::optional<int>    i = boost::convert<int>("12");
+boost::optional<string> s = boost::convert<string>(123.456);
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm10655.html b/doc/html/boost/convert_idm10655.html new file mode 100644 index 0000000..7238ff0 --- /dev/null +++ b/doc/html/boost/convert_idm10655.html @@ -0,0 +1,94 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert main deployment interface.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  boost::optional< TypeOut > 
+  convert(TypeIn const & value_in, Converter const & converter);
+
+

Description

+

+ +For example,

+
boost::cnv::cstream cnv;
+
+boost::optional<int>    i = boost::convert<int>("12", cnv);
+boost::optional<string> s = boost::convert<string>(123.456, cnv);
+
+

+
++++ + + + + + + + + + + +

Parameters:

++++ + + + + + + + + + + +

converter

Converter to be used for conversion

value_in

Value of the TypeIn type to be converted to the TypeOut type

Returns:

boost::optional<TypeOut> result of conversion together with the indication of success or failure of the conversion request.

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm10675.html b/doc/html/boost/convert_idm10675.html new file mode 100644 index 0000000..5b3e2d4 --- /dev/null +++ b/doc/html/boost/convert_idm10675.html @@ -0,0 +1,62 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert deployment interface with the default converter.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn> 
+  boost::optional< TypeOut > convert(TypeIn const & value_in);
+
+

Description

+

For example,

+
struct boost::cnv::by_default : boost::cnv::cstream {};
+
+// boost::cnv::cstream (through boost::cnv::by_default) is deployed
+// as the default converter when no converter is provided explicitly.
+boost::optional<int>    i = boost::convert<int>("12");
+boost::optional<string> s = boost::convert<string>(123.456);
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm46323361447440.html b/doc/html/boost/convert_idm46323361447440.html new file mode 100644 index 0000000..8f6dd69 --- /dev/null +++ b/doc/html/boost/convert_idm46323361447440.html @@ -0,0 +1,62 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert deployment interface with the default converter.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn> 
+  boost::optional< TypeOut > convert(TypeIn const & value_in);
+
+

Description

+

For example,

+
struct boost::cnv::by_default : boost::cnv::cstream {};
+
+// boost::cnv::cstream (through boost::cnv::by_default) is deployed
+// as the default converter when no converter is provided explicitly.
+boost::optional<int>    i = boost::convert<int>("12");
+boost::optional<string> s = boost::convert<string>(123.456);
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/convert_idm46323361454688.html b/doc/html/boost/convert_idm46323361454688.html new file mode 100644 index 0000000..0ce0ea2 --- /dev/null +++ b/doc/html/boost/convert_idm46323361454688.html @@ -0,0 +1,94 @@ + + + +Function template convert + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template convert

+

boost::convert — Boost.Convert main deployment interface.

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+
+template<typename TypeOut, typename TypeIn, typename Converter> 
+  boost::optional< TypeOut > 
+  convert(TypeIn const & value_in, Converter const & converter);
+
+

Description

+

+ +For example,

+
boost::cnv::cstream cnv;
+
+boost::optional<int>    i = boost::convert<int>("12", cnv);
+boost::optional<string> s = boost::convert<string>(123.456, cnv);
+
+

+
++++ + + + + + + + + + + +

Parameters:

++++ + + + + + + + + + + +

converter

Converter to be used for conversion

value_in

Value of the TypeIn type to be converted to the TypeOut type

Returns:

boost::optional<TypeOut> result of conversion together with the indication of success or failure of the conversion request.

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/make_default.html b/doc/html/boost/make_default.html new file mode 100644 index 0000000..16cbf7e --- /dev/null +++ b/doc/html/boost/make_default.html @@ -0,0 +1,70 @@ + + + +Function template make_default + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Function template make_default

+

boost::make_default

+
+

Synopsis

+
// In header: <boost/make_default.hpp>
+
+
+template<typename T> T make_default();
+
+

Description

+

A considerable number of libraries require an instance of a class provided (storage created and initialized). For example,

+
Type result;
+...
+istream >> result;
+
+

In generic code that results in the Default Constructibility requirement imposed on every type 'Type' to be used with the respective code. Inevitably, that requirement a) either excludes all the classes that for various reasons do not meet that requirement or b) imposes certain (not necessarily desirable) design/implementation onto respective classes.

+

Deployment of boost::make_default() eliminates the Default Constructibility requirement with

+
Type result = boost::make_default<Type>();
+...
+istream >> result;
+
+

Classes with no default constructor can now be included via a boost::make_default() specialization:

+
namespace boost
+{
+    template<> inline Type make_default<Type>() { return Type(parameters); }
+}
+
+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost/throw_on_failure.html b/doc/html/boost/throw_on_failure.html new file mode 100644 index 0000000..7316982 --- /dev/null +++ b/doc/html/boost/throw_on_failure.html @@ -0,0 +1,52 @@ + + + +Global throw_on_failure + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+
+
+

Global throw_on_failure

+

boost::throw_on_failure

+
+

Synopsis

+
// In header: <boost/convert.hpp>
+
+unspecified throw_on_failure;
+
+

Description

+

boost::throw_on_failure is the 'tag' object to request the exception-throwing behavior.

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/acknowledgements.html b/doc/html/boost_convert/acknowledgements.html new file mode 100644 index 0000000..6ce9a83 --- /dev/null +++ b/doc/html/boost_convert/acknowledgements.html @@ -0,0 +1,79 @@ + + + +Acknowledgements + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Many thanks to Julian Gonggrijp, Rob Stewart, Andrzej Krzemienski, Matus Chochlik, + Jeroen Habraken, Hartmut Kaiser, Joel De Guzman, Thijs (M.A.) van den Berg, + Roland Bock, Gavin Lambert, Paul Bristow, Alex Hagen-Zanker, Christopher Kormanyos + for taking part in the Boost.Convert review and their + valuable input. +

+

+ Special thanks to: +

+
    +
  • + Alex Hagen-Zanker, Roland Bock, Rob Stewart for their considerable and + continuous contributions to the design and implementation of the library; +
  • +
  • + Andrzej Krzemienski for helping to partition responsibilities and to ultimately + pave the way for the boost::optional + and std::tr2::optional deployment; +
  • +
  • + Edward Diener the Boost Review Manager for helping with the converters' + design, his continuous involvement, technical and administrative help, + guidance and advice; +
  • +
  • + Joel De Guzman, Rob Stewart and Alex Hagen-Zanker for making sure the performance + tests work as they should; +
  • +
  • + Paul Bristow for helping great deal with the documentation; +
  • +
  • + Kevlin Henney and Dave Abrahams for their lexical_cast-related insights + and explanations. +
  • +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/algorithms.html b/doc/html/boost_convert/algorithms.html new file mode 100644 index 0000000..5340d62 --- /dev/null +++ b/doc/html/boost_convert/algorithms.html @@ -0,0 +1,258 @@ + + + +Boost.Convert with Standard Algorithms + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The following code demonstrates a failed attempt (and one of the reasons Boost.Convert + has been developed) to convert a few strings + to ints with boost::lexical_cast: +

+

+

+
std::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>           ints;
+
+try
+{
+    std::transform(strs.begin(), strs.end(), std::back_inserter(ints),
+        std::bind(boost::lexical_cast<int, string>, std::placeholders::_1));
+
+    BOOST_TEST(0 && "Never reached!");
+}
+catch (std::exception&)
+{
+    BOOST_TEST(ints.size() == 0); // No strings converted.
+}
+
+

+

+

+ If the exception-throwing behavior is the desired behavior, then Boost.Convert + supports that. In addition, it also supports a non-throwing process-flow: +

+

+

+
std::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>           ints;
+
+std::transform(strs.begin(), strs.end(), std::back_inserter(ints),
+    boost::cnv::apply<int>(boost::cnv::lexical_cast()).value_or(-1));
+
+BOOST_TEST(ints.size() == 3);
+BOOST_TEST(ints[0] == -1); // Failed conversion does not throw.
+BOOST_TEST(ints[1] == -1); // Failed conversion does not throw.
+BOOST_TEST(ints[2] == -1); // Failed conversion does not throw.
+
+

+

+

+ Deploying boost::cnv::cstream + with better formatting capabilities yields better results with exception-throwing + and non-throwing process-flows still supported: +

+

+

+
std::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>           ints;
+boost::cnv::cstream         cnv;
+
+try
+{
+    std::transform(strs.begin(), strs.end(), std::back_inserter(ints),
+        boost::cnv::apply<int>(std::cref(cnv(std::hex)(std::skipws))));
+
+    BOOST_TEST(0 && "Never reached!");
+}
+catch (boost::bad_optional_access const&)
+{
+    BOOST_TEST(ints.size() == 2); // Only the first two strings converted.
+    BOOST_TEST(ints[0] ==  5);    // " 5"
+    BOOST_TEST(ints[1] == 15);    // "0XF"
+
+    // "not an int" causes the exception thrown.
+}
+
+

+

+

+

+
std::transform(strs.begin(), strs.end(), std::back_inserter(ints),
+    boost::cnv::apply<int>(std::cref(cnv(std::hex)(std::skipws))).value_or(-1));
+
+BOOST_TEST(ints.size() == 3);
+BOOST_TEST(ints[0] ==  5);
+BOOST_TEST(ints[1] == 15);
+BOOST_TEST(ints[2] == -1); // Failed conversion
+
+

+

+
+ + + + + +
[Important]Important
+

+ One notable difference in the deployment of boost::cnv::cstream with algorithms is the use of + std::cref. +

+

+ It needs to be remembered that with standard algorithms the deployed converter + needs to be copyable + or movable + (C++11) and is, in fact, copied or moved by the respective algorithm + before being used. Given that std::cstringstream + is not copyable, boost::cnv::cstream + is not copyable either. That limitation is routinely worked-around using + std::ref or std::cref. +

+
+

+ And now an example of algorithm-based integer-to-string formatted conversion + with std::hex, std::uppercase + and std::showbase formatting applied: +

+

+

+
std::array<int, 3>       ints = {{ 15, 16, 17 }};
+std::vector<std::string> strs;
+boost::cnv::cstream       cnv;
+
+cnv(std::hex)(std::uppercase)(std::showbase);
+
+std::transform(ints.begin(), ints.end(), std::back_inserter(strs),
+    boost::cnv::apply<string>(std::cref(cnv)));
+
+BOOST_TEST(strs.size() == 3);
+BOOST_TEST(strs[0] ==  "0XF"); // 15
+BOOST_TEST(strs[1] == "0X10"); // 16
+BOOST_TEST(strs[2] == "0X11"); // 17
+
+

+

+

+ + Forced + TypeIn vs. Deduced +

+

+ So far it was sufficient to explicitly specify only one type to boost::cnv::apply<TypeOut> + -- the target TypeOut type. The source TypeIn + type was provided implicitly through the algorithm and often it all just works + (as the examples above demonstrate). However, at times more control is needed + regarding the TypeIn type and boost::cnv::apply() provides + such control via explicit specification of TypeIn -- + boost::cnv::apply<TypeOut, TypeIn>. +

+

+ The following example demonstrates an interesting issue related to the change class introduced in Integration of User-Defined + Types. The class is essentially a glorified enum, a user-friendly convenience + wrapper around the actual enum + value_type { + no, up, dn + }. In the example an array + of change + values (chgs1) is sensibly + converted to readable "no", "up" and "dn" strings + (strs1) when an array of change::value_type values (chgs2) converts to obscure "0", + "1" and "2" (strs2). +

+

+

+
std::array<change, 3>             chgs1 = {{ change::no, change::up, change::dn }};
+std::array<change::value_type, 3> chgs2 = {{ change::no, change::up, change::dn }};
+
+auto strs1 = std::vector<std::string>();
+auto strs2 = std::vector<std::string>();
+auto strs3 = std::vector<std::string>();
+auto   cnv = boost::cnv::cstream();
+
+std::transform(chgs1.begin(), chgs1.end(), std::back_inserter(strs1),
+    boost::cnv::apply<string>(std::cref(cnv))); // Deduced TypeIn is 'change'
+
+std::transform(chgs2.begin(), chgs2.end(), std::back_inserter(strs2),
+    boost::cnv::apply<string>(std::cref(cnv))); // Deduced TypeIn is 'change::value_type'
+
+BOOST_TEST(strs1.size() == 3);
+BOOST_TEST(strs1[0] == "no");
+BOOST_TEST(strs1[1] == "up");
+BOOST_TEST(strs1[2] == "dn");
+
+BOOST_TEST(strs2.size() == 3);
+BOOST_TEST(strs2[0] == "0");
+BOOST_TEST(strs2[1] == "1");
+BOOST_TEST(strs2[2] == "2");
+
+

+

+

+ The boost::cnv::apply<TypeOut, TypeIn> with forced (rather than deduced) TypeIn + comes to the rescue and converts the array of change::value_type + values (chgs2) to sensible + "no", "up" and "dn" (strs3): +

+

+

+
std::transform(chgs2.begin(), chgs2.end(), std::back_inserter(strs3),
+    boost::cnv::apply<string, change>(std::cref(cnv)));
+
+BOOST_TEST(strs3.size() == 3);
+BOOST_TEST(strs3[0] == "no");
+BOOST_TEST(strs3[1] == "up");
+BOOST_TEST(strs3[2] == "dn");
+
+

+

+
+ + + + + +
[Note]Note

+ For demonstration purposes the example above is made as simple as possible + and, consequently, the described "issue" could probably be addressed + by other means. Still, do not let my inability to come up with a better (complex + but short and representative) example get in the way of appreciating the + described functionality. I do not expect it to be used often but it is here + when you need it. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/alternative_interface.html b/doc/html/boost_convert/alternative_interface.html new file mode 100644 index 0000000..ad56a31 --- /dev/null +++ b/doc/html/boost_convert/alternative_interface.html @@ -0,0 +1,110 @@ + + + +Alternative Interface + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ "It's not a question of happiness, it's + a requirement. Consider the alternative” Doug Horton +

+

+ As it was indicated previously boost::optional + is the actual type returned by the boost::convert() main interface: +

+
boost::optional<TypeOut> boost::convert(TypeIn const&, Converter const&);
+
+

+ The signature is functionally-complete and routinely elided + during compilation. Still, the following alternative (and arguably more traditional) + interface might be potentially more suitable for certain deployment scenarios + (or due to personal preferences): +

+
TypeOut convert(TypeIn const&, Converter const&, TypeOut const& fallback_value);
+TypeOut convert(TypeIn const&, Converter const&, Functor const& fallback_func);
+TypeOut convert(TypeIn const&, Converter const&, boost::throw_on_failure);
+
+

+ The interface still provides unambiguous behavior and readability, full support + for various program flows and various degrees of conversion-failure detection + and processing. It can be deployed in a similar fashion as follows: +

+

+

+
struct fallback_func
+{
+    int operator()() const { log("Failed to convert"); return 42; }
+};
+
+

+

+

+

+
// Error-processing behavior are specified unambiguously and uniformly.
+// a) i1: Returns the provided fallback value;
+// b) i2: Calls the provided failure-processing function;
+// c) i3: Throws an exception.
+
+int i1 = convert<int>(str, cnv, fallback_value);
+int i2 = convert<int>(str, cnv, fallback_func());
+
+try
+{
+    // Throwing behavior specified explicitly rather than implied.
+    int i3 = convert<int>(str, cnv, boost::throw_on_failure);
+}
+catch (boost::bad_optional_access const&)
+{
+  // Handle failed conversion.
+}
+
+

+

+

+ Still, the described interfaces are convenience wrappers around the main interface + which provides the described behavior with: +

+

+

+
int m1 = convert<int>(str, cnv).value_or(fallback_value);
+int m2 = convert<int>(str, cnv).value_or_eval(fallback_func());
+int m3 = convert<int>(str, cnv).value();
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters.html b/doc/html/boost_convert/converters.html new file mode 100644 index 0000000..422a887 --- /dev/null +++ b/doc/html/boost_convert/converters.html @@ -0,0 +1,190 @@ + + + +Converters + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The boost::convert() + API plays its role by providing a uniform interface and + ensuring consistent behavior. However, it is the respective + converter which does the hard work of actual type conversion/transformation. +

+

+ Boost.Convert design reflects the fact that no one converter + is to satisfy all imaginable conversion/transformation-related user requirements. + Consequently, extendibility and converter pluggability + are important properties of Boost.Convert. The library + provides several converters for common type conversions with varying degrees + of formatting support and performance. However, it is an expectation that more + generic-purpose and custom-specific converters are to be written and deployed + with Boost.Convert. +

+

+ For a converter to be plugged in to the Boost.Convert + framework it needs to be a callable with one of the signatures: +

+
template<typename TypeOut, typename TypeIn>
+void operator()(TypeIn const& value_in, boost::optional<TypeOut>& result_out) const;
+
+template<typename TypeOut, typename TypeIn>
+void operator()(TypeIn value_in, boost::optional<TypeOut>& result_out) const;
+
+

+ if that is a general-purpose converter capable of handling many types (like + string-to-type and type-to-string conversions). Alternatively, a purpose-built + custom converter might only care to provide +

+
void operator()(TypeIn const&, boost::optional<TypeOut>&) const;
+
+

+ if its sole purpose is to handle one specific conversion/transformation of + TypeIn to TypeOut. For example, a + converter from the operating-system-specific MBCS string format to the UCS-2 + or UCS-4 (depending on wchar_t + size) might be one such example: +

+
void operator()(std::string const&, boost::optional<std::wstring>&) const;
+
+

+ Alternatively again, an ad-hoc in-place callable might + be provided as a converter. For example, +

+

+

+
using std::string;
+using boost::lexical_cast;
+using boost::convert;
+
+

+

+

+

+
int v03 = convert<int>(str,
+              std::bind(assign<int>, std::placeholders::_2,
+                  std::bind(lexical_cast<int, string>, std::placeholders::_1))).value_or(-1);
+
+

+

+

+ or an old-fashioned function: +

+

+

+
void plain_old_func(string const& value_in, boost::optional<int>& value_out)
+
+

+

+

+

+
int v01 = convert<int>(str, plain_old_func).value_or(-1);
+
+

+

+

+ With regard to converters the Boost.Convert framework + has been designed with the following requirement in mind: +

+
+ + + + + +
[Note]Note

+ Converters shall be independent from and must not rely on the Boost.Convert + infrastructure. +

+

+ + Implicit + TypeIn Promotions and Conversions +

+

+ It is worth remembering that TypeIn in the signature should + be interpreted in the context of the potential implicit type promotions and + conversions allowed by the language. For example, depending + on the context the take_double + and take_int converters below + might not do what is expected of them due to implicit int-to-double + promotion and value-destroying double-to-int conversion + applied by the compiler: +

+

+

+
struct take_double { void operator()(double, boost::optional<string>&) const {}};
+struct    take_int { void operator()(int, boost::optional<string>&) const {}};
+
+

+

+

+

+
convert<string>(11, take_double()); // Compiler applies int-to-double promotion to call the converter.
+convert<string>(11.23, take_int()); // Compiler applies double-to-int implicit truncation.
+
+

+

+

+ boost::convert() + API does not modify TypeIn or interpret it in any way. + The passed-in value and its type are delivered to the underlying converter + as-is. Consequently, if potential implicit type promotions and conversions + are not desirable, then it is the converter's responsibility to address that + issue. For example, one way to disable implicit conversions might be: +

+

+

+
struct double_only
+{
+    // Declared for all types.
+    template<typename TypeIn> void operator()(TypeIn, boost::optional<string>&) const;
+};
+
+// Defined only for certain types.
+template<> void double_only::operator()<double>(double, boost::optional<string>&) const {}
+
+

+

+

+

+
    convert<string>(11.23, double_only()); // Fine.
+//  convert<string>(11,    double_only()); // Fails: undefined reference to double_only::operator()<int>
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail.html b/doc/html/boost_convert/converters_detail.html new file mode 100644 index 0000000..e29f55d --- /dev/null +++ b/doc/html/boost_convert/converters_detail.html @@ -0,0 +1,185 @@ + + + +Converters in Detail + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +
+ +

+ 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: +

+

+

+
#include <boost/convert.hpp>
+#include <boost/convert/lexical_cast.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+using std::string;
+using boost::convert;
+using boost::lexical_cast;
+
+struct boost::cnv::by_default : boost::cnv::lexical_cast {};
+
+

+

+

+

+
int    i1 = lexical_cast<int>("123");         // Throws if the conversion fails.
+int    i2 = convert<int>("123").value();      // Throws if the conversion fails.
+int    i3 = convert<int>("uhm").value_or(-1); // Returns -1 if the conversion fails.
+string s1 = lexical_cast<string>(123);
+string s2 = convert<string>(123).value();
+
+BOOST_TEST(i1 == 123);
+BOOST_TEST(i2 == 123);
+BOOST_TEST(i3 == -1);
+BOOST_TEST(s1 == "123");
+BOOST_TEST(s2 == "123");
+
+

+

+

+ See the 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: +

+
+

+ 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. +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/stream_converter.html b/doc/html/boost_convert/converters_detail/stream_converter.html new file mode 100644 index 0000000..d17fe2b --- /dev/null +++ b/doc/html/boost_convert/converters_detail/stream_converter.html @@ -0,0 +1,385 @@ + + + +boost::cnv::stream Converter + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ The purpose of the converter is to provide conversion-related formatting + and locale support not available with boost::lexical_cast. + Advantages of deploying a std::stream-based + conversion engine are: +

+
    +
  • + availability and maturity; +
  • +
  • + formatting and locale support; +
  • +
  • + familiar interface and deployment; +
  • +
  • + instant re-use of available standard manipulators (std::hex, + std::setprecision, std::skipws, + etc.); +
  • +
  • + extendibility via custom manipulators (see Stream + Storage for Private Use: iword, pword, and xalloc by Rogue Wave + Software). +
  • +
+

+ The converter might be deployed as follows: +

+

+

+
#include <boost/convert.hpp>
+#include <boost/convert/stream.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+using std::string;
+using boost::convert;
+
+struct boost::cnv::by_default : boost::cnv::cstream {};
+
+

+

+

+

+
int    i2 = convert<int>("123").value();      // Throws when fails.
+int    i3 = convert<int>("uhm").value_or(-1); // Returns -1 when fails.
+string s2 = convert<string>(123).value();
+
+BOOST_TEST(i2 == 123);
+BOOST_TEST(i3 == -1);
+BOOST_TEST(s2 == "123");
+
+

+

+
+ + +

+ Formatting support is provided by the underlying std::stringstream. + Consequently, the API heavily borrows formatting metaphors from this underlying + component. One such metaphor is the manipulator represented + by std::hex, std::dec, + std::uppercase, std::scientific, + etc. +

+

+ The following code demonstrates how char + and wchar_t strings can be + read in the std::hex or std::dec + format: +

+

+

+
boost::cnv::cstream ccnv;
+boost::cnv::wstream wcnv;
+
+int v01 = convert<int>("  FF", ccnv(std::hex)(std::skipws)).value_or(0);
+int v02 = convert<int>(L"  F", wcnv(std::hex)(std::skipws)).value_or(0);
+int v03 = convert<int>("  FF", ccnv(std::dec)(std::skipws)).value_or(-5);
+int v04 = convert<int>(L"  F", wcnv(std::dec)(std::skipws)).value_or(-5);
+
+BOOST_TEST(v01 == 255); // "FF"
+BOOST_TEST(v02 ==  15); // L"F"
+BOOST_TEST(v03 ==  -5); // Failed to convert "FF" as decimal.
+BOOST_TEST(v04 ==  -5); // Failed to convert L"F" as decimal.
+
+

+

+

+ For batch-processing it might be more efficient to configure the converter + once: +

+

+

+
ccnv(std::showbase)(std::uppercase)(std::hex);
+
+BOOST_TEST(convert<string>(255, ccnv, "bad") == "0XFF");
+BOOST_TEST(convert<string>( 15, ccnv, "bad") ==  "0XF");
+
+

+

+

+ An alternative (generic) formatting interface is currently being extended + and explored: +

+

+

+
namespace cnv = boost::cnv;
+namespace arg = boost::cnv::parameter;
+
+

+

+

+

+
ccnv(arg::base = cnv::base::dec)
+    (arg::uppercase = true)
+    (arg::notation = cnv::notation::scientific);
+
+

+

+

+ is equivalent to the following std::manipulator-based + variant: +

+

+

+
ccnv(std::dec)(std::uppercase)(std::scientific);
+
+

+

+
+ +

+

+
using std::string;
+using std::wstring;
+using boost::convert;
+
+

+

+

+ The following example demonstrates the deployment of std::dec, + std::oct std::hex + manipulators: +

+

+

+
boost::cnv::cstream ccnv;
+
+BOOST_TEST(convert<int>( "11", ccnv(std::hex)).value_or(0) == 17); // 11(16) = 17(10)
+BOOST_TEST(convert<int>( "11", ccnv(std::oct)).value_or(0) ==  9); // 11(8)  = 9(10)
+BOOST_TEST(convert<int>( "11", ccnv(std::dec)).value_or(0) == 11);
+
+BOOST_TEST(convert<string>( 18, ccnv(std::hex)).value_or("bad") == "12"); // 18(10) = 12(16)
+BOOST_TEST(convert<string>( 10, ccnv(std::oct)).value_or("bad") == "12"); // 10(10) = 12(8)
+BOOST_TEST(convert<string>( 12, ccnv(std::dec)).value_or("bad") == "12");
+BOOST_TEST(convert<string>(255, ccnv(arg::base = boost::cnv::base::oct)).value_or("bad") == "377");
+BOOST_TEST(convert<string>(255, ccnv(arg::base = boost::cnv::base::hex)).value_or("bad") ==  "ff");
+BOOST_TEST(convert<string>(255, ccnv(arg::base = boost::cnv::base::dec)).value_or("bad") == "255");
+
+ccnv(std::showbase);
+
+BOOST_TEST(convert<string>(18, ccnv(std::hex)).value_or("bad") == "0x12");
+BOOST_TEST(convert<string>(10, ccnv(std::oct)).value_or("bad") ==  "012");
+
+ccnv(std::uppercase);
+
+BOOST_TEST(convert<string>(18, ccnv(std::hex)).value_or("bad") == "0X12");
+
+

+

+

+ A more generic interface is also supported: +

+

+

+
namespace cnv = boost::cnv;
+namespace arg = boost::cnv::parameter;
+
+

+

+

+

+
BOOST_TEST(convert<int>("11", ccnv(arg::base = cnv::base::hex)).value_or(0) == 17);
+BOOST_TEST(convert<int>("11", ccnv(arg::base = cnv::base::oct)).value_or(0) ==  9);
+BOOST_TEST(convert<int>("11", ccnv(arg::base = cnv::base::dec)).value_or(0) == 11);
+
+

+

+
+
+ +

+

+
boost::cnv::cstream cnv;
+
+boost::optional<string> s01 = convert<string>(12, cnv(std::setw(4)));
+boost::optional<string> s02 = convert<string>(12, cnv(std::setw(5))(std::setfill('*')));
+boost::optional<string> s03 = convert<string>(12, cnv(std::setw(5))(std::setfill('*'))(std::left));
+
+BOOST_TEST(s01 && s01.value() == "  12");  // Field width = 4.
+BOOST_TEST(s02 && s02.value() == "***12"); // Field width = 5, filler = '*'.
+BOOST_TEST(s03 && s03.value() == "12***"); // Field width = 5, filler = '*', left adjustment
+
+

+

+

+ It needs to be remembered that boost::cnv::stream + converter uses std::stream as its underlying conversion + engine. Consequently, formatting-related behavior are driven by the + std::stream. Namely, after every operation + is performed, the default field width is restored. + The values of the fill character and the adjustment remain unchanged + until they are modified explicitly. +

+

+

+
// The fill and adjustment remain '*' and 'left'.
+boost::optional<string> s11 = convert<string>(12, cnv(arg::width = 4));
+boost::optional<string> s12 = convert<string>(12, cnv(arg::width = 5)
+                                                     (arg::fill = ' ')
+                                                     (arg::adjust = cnv::adjust::right));
+
+BOOST_TEST(s11 && s11.value() == "12**");  // Field width was set to 4.
+BOOST_TEST(s12 && s12.value() == "   12"); // Field width was set to 5 with the ' ' filler.
+
+

+

+
+
+ +

+

+
using std::string;
+using std::wstring;
+using boost::convert;
+
+

+

+

+

+
    boost::cnv::cstream    ccnv;
+    char const* const cstr_good = "  123";
+    char const* const  cstr_bad = "  123 "; // std::skipws only affects leading spaces.
+
+    ccnv(std::skipws);        // Ignore leading whitespaces
+//  ccnv(arg::skipws = true); // Ignore leading whitespaces. Alternative interface
+
+    BOOST_TEST(convert<int>(cstr_good, ccnv).value_or(0) == 123);
+    BOOST_TEST(convert<string>("  123", ccnv).value_or("bad") == "123");
+
+    BOOST_TEST(!convert<int>(cstr_bad, ccnv));
+
+    ccnv(std::noskipws);       // Do not ignore leading whitespaces
+//  ccnv(arg::skipws = false); // Do not ignore leading whitespaces. Alternative interface
+
+    // All conversions fail.
+    BOOST_TEST(!convert<int>(cstr_good, ccnv));
+    BOOST_TEST(!convert<int>( cstr_bad, ccnv));
+
+

+

+
+
+ +

+

+
using std::string;
+using std::wstring;
+using boost::convert;
+
+

+

+

+

+
BOOST_TEST(convert<string>( true, cnv(std::boolalpha)).value_or("bad") ==  "true");
+BOOST_TEST(convert<string>(false, cnv(std::boolalpha)).value_or("bad") == "false");
+
+BOOST_TEST(convert<bool>( "true", cnv(std::boolalpha)).value_or(false) ==  true);
+BOOST_TEST(convert<bool>("false", cnv(std::boolalpha)).value_or( true) == false);
+
+BOOST_TEST(convert<string>( true, cnv(std::noboolalpha)).value_or("bad") == "1");
+BOOST_TEST(convert<string>(false, cnv(std::noboolalpha)).value_or("bad") == "0");
+
+BOOST_TEST(convert<bool>("1", cnv(std::noboolalpha)).value_or(false) ==  true);
+BOOST_TEST(convert<bool>("0", cnv(std::noboolalpha)).value_or( true) == false);
+
+

+

+
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/stream_converter/locale_support.html b/doc/html/boost_convert/converters_detail/stream_converter/locale_support.html new file mode 100644 index 0000000..db0b2a6 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/stream_converter/locale_support.html @@ -0,0 +1,93 @@ + + + +Locale Support + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Locale support is similar to the formatting support as demonstrated by + the following example: +

+

+

+
namespace cnv = boost::cnv;
+namespace arg = boost::cnv::parameter;
+
+

+

+

+

+
    boost::cnv::cstream cnv;
+    std::locale  rus_locale;
+    std::locale  eng_locale;
+
+    char const* eng_locale_name = test::cnv::is_msc ? "English_United States.1251" : "en_US.UTF-8";
+    char const* rus_locale_name = test::cnv::is_msc ? "Russian_Russia.1251" : "ru_RU.UTF-8";
+    char const*    rus_expected = test::cnv::is_msc ? "1,235e-002"  : "1,235e-02";
+    char const*    eng_expected = test::cnv::is_msc ? "1.235e-002"  : "1.235e-02";
+    char const*    dbl_expected = test::cnv::is_msc ? "1.2345E-002" : "1.2345E-02";
+
+//  cnv(std::setprecision(4))(std::uppercase)(std::scientific);
+    cnv(arg::precision = 4)
+       (arg::uppercase = true)
+       (arg::notation = cnv::notation::scientific);
+
+    double double_v01 = convert<double>(dbl_expected, cnv).value_or(0);
+    string double_s02 = convert<string>(double_v01, cnv).value_or("bad");
+
+    BOOST_TEST(dbl_expected == double_s02);
+
+    try { rus_locale = std::locale(rus_locale_name); }
+    catch (...) { printf("Bad locale %s.\n", rus_locale_name); exit(1); }
+
+    try { eng_locale = std::locale(eng_locale_name); }
+    catch (...) { printf("Bad locale %s.\n", eng_locale_name); exit(1); }
+
+//  cnv(std::setprecision(3))(std::nouppercase);
+    cnv(arg::precision = 3)(arg::uppercase = false);
+
+    string double_rus = convert<string>(double_v01, cnv(rus_locale)).value_or("bad double_rus");
+    string double_eng = convert<string>(double_v01, cnv(eng_locale)).value_or("bad double_eng");
+
+    BOOST_TEST(double_rus == rus_expected);
+    BOOST_TEST(double_eng == eng_expected);
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/stream_converter/supported_string_types.html b/doc/html/boost_convert/converters_detail/stream_converter/supported_string_types.html new file mode 100644 index 0000000..6ef5e57 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/stream_converter/supported_string_types.html @@ -0,0 +1,87 @@ + + + +Supported String Types + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +
+ +

+

+
boost::cnv::wstream wcnv;
+
+BOOST_TEST(convert<int>(L"11", wcnv(std::hex)).value_or(0) == 17); // 11(16) = 17(10)
+BOOST_TEST(convert<int>(L"11", wcnv(std::oct)).value_or(0) ==  9); // 11(8)  = 9(10)
+BOOST_TEST(convert<int>(L"11", wcnv(std::dec)).value_or(0) == 11);
+
+BOOST_TEST(convert<wstring>(254, wcnv(arg::base = cnv::base::dec)).value_or(L"bad") == L"254");
+BOOST_TEST(convert<wstring>(254, wcnv(arg::base = cnv::base::hex)).value_or(L"bad") ==  L"fe");
+BOOST_TEST(convert<wstring>(254, wcnv(arg::base = cnv::base::oct)).value_or(L"bad") == L"376");
+
+

+

+

+

+
    boost::cnv::wstream wcnv;
+
+    wcnv(std::noskipws); // Do not ignore leading whitespaces
+
+    BOOST_TEST( convert<int>(   L"123", wcnv).value_or(0) == 123);
+    BOOST_TEST(!convert<int>( L"  123", wcnv));
+    BOOST_TEST(!convert<int>(L"  123 ", wcnv));
+
+    wcnv(std::skipws);        // Ignore leading whitespaces
+//  wcnv(arg::skipws = true); // Ignore leading whitespaces. Alternative interface
+
+    BOOST_TEST( convert<int>( L"  123", wcnv).value_or(0) == 123);
+    BOOST_TEST(!convert<int>(L"  123 ", wcnv));
+
+

+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/stream_converter/supported_string_types/custom_string_types.html b/doc/html/boost_convert/converters_detail/stream_converter/supported_string_types/custom_string_types.html new file mode 100644 index 0000000..b5a4639 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/stream_converter/supported_string_types/custom_string_types.html @@ -0,0 +1,92 @@ + + + +Custom String Types + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ boost::cnv::stream accepts custom string and string-like + types as input or output as long as they satisfy certain requirements. +

+

+

+
boost::cnv::cstream cnv;
+my_string        my_str("123");
+
+cnv(std::setprecision(2))(std::fixed);
+
+BOOST_TEST(convert<int>(my_str, cnv).value_or(0) == 123);
+
+BOOST_TEST(convert<my_string>( 99.999, cnv).value_or("bad") == "100.00");
+BOOST_TEST(convert<my_string>( 99.949, cnv).value_or("bad") ==  "99.95");
+BOOST_TEST(convert<my_string>(-99.949, cnv).value_or("bad") == "-99.95");
+
+

+

+

+ When a string-like type is the source, then it needs to be a contiguous + sequence of the corresponding character type (char or wchar_t) + accessible via begin() and end(). +

+

+ std::stringstream is implemented entirely + in terms of std::basic_streambuf which, in turn, operates + on a contiguous character sequence, also called + the buffer (see std::basic_streambuf for details). + For efficiency reasons boost::cnv::stream + uses the provided (read-only) input string as the buffer + and, consequently, requires that provided input string to be a contiguous + character sequence. +

+

+ When a string is the target, then the described contiguous + character sequence requirement does not apply. Any type that + provides +

+
MyType::MyType(char const* beg, char const* end)
+
+

+ constructor can be deployed in type-to-string conversions. +

+

+ See The + Bigger Picture chapter for the discussion of potential advantages + of deploying custom strings. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/stream_converter/the___default_constructible__type_requirement.html b/doc/html/boost_convert/converters_detail/stream_converter/the___default_constructible__type_requirement.html new file mode 100644 index 0000000..82d9213 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/stream_converter/the___default_constructible__type_requirement.html @@ -0,0 +1,152 @@ + + + +The Default Constructible Type Requirement + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Due to std::stream design it requires an initialized + temporary storage of TypeOut type to put the result + of the requested conversion to. Conceptually boost::cnv::cstream + achieves that with: +

+
istream_type& istream = stream_;
+TypeOut        result = boost::make_default<TypeOut>();
+
+istream >> result;
+
+

+ The temporary storage result + is initialized with boost::make_default() the default implementation of which is +

+
namespace boost
+{
+   template<typename T> T make_default() { return T(); }
+}
+
+

+ Consequently, +

+
+ + + + + +
[Note]Note

+ By default the boost::cnv::cstream + and boost::cnv::wstream converters require the TypeOut + type to be Default + Constructible. +

+

+ That said, a well-designed type (in my opinion, anyway) should only have + meaningful and unambiguous constructors... and the default constructor + is not always and necessarily one of them. Consider the following as one + such example: +

+

+

+
struct direction
+{
+    // Note: the class does NOT have the default constructor.
+
+    enum value_type { up, dn };
+
+    direction(value_type value) : value_(value) {}
+    bool operator==(direction that) const { return value_ == that.value_; }
+    value_type value() const { return value_; }
+
+    private: value_type value_;
+};
+
+

+

+

+

+
std::istream& operator>>(std::istream& stream, direction& dir)
+{
+    std::string str; stream >> str;
+
+    /**/ if (str == "up") dir = direction::up;
+    else if (str == "dn") dir = direction::dn;
+    else stream.setstate(std::ios_base::failbit);
+
+    return stream;
+}
+std::ostream& operator<<(std::ostream& stream, direction const& dir)
+{
+    return stream << (dir.value() == direction::up ? "up" : "dn");
+}
+
+

+

+

+ The direction type has + no default state. It is not Default + Constructible and, consequently, the following does + not compile: +

+
direction dir1 = convert<direction>(str, cnv).value(); // Does not compile
+direction dir2 = lexical_cast<direction>(str);         // Does not compile
+
+

+ However, Boost.Convert is able to handle such a type + with little help from the user -- the instructions how + to create that mentioned temporary storage: +

+

+

+
namespace boost
+{
+    template<> inline direction make_default<direction>()
+    {
+        return direction(direction::up);
+    }
+}
+
+

+

+

+ Now such class can be deployed with boost::cnv::cstream: +

+
direction dir1 = convert<direction>(str, cnv).value(); // Compiles
+direction dir2 = lexical_cast<direction>(str); // Does not compile
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/strtol_converter.html b/doc/html/boost_convert/converters_detail/strtol_converter.html new file mode 100644 index 0000000..43bae5c --- /dev/null +++ b/doc/html/boost_convert/converters_detail/strtol_converter.html @@ -0,0 +1,114 @@ + + + +boost::cnv::strtol Converter + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ The converter started as a deployment example (with the std::strtol + family of functions as its conversion engine) and a part of the performance-test + set. Surprisingly, the converter showed fairly decent all-around performance + (see Converters + Compared) and, consequently, has been rewritten and extended to provide + additional conversion support and formatting. At the moment it seems to be + a good choice with moderate formatting facilities and adequate performance. +

+

+ It should be noted though that the converter is nowhere as mature as boost::cnv::lexical_cast + or boost::cnv::stream + and, therefore, bugs are to be expected. +

+
+ +

+

+
#include <boost/convert.hpp>
+#include <boost/convert/strtol.hpp>
+
+using std::string;
+using std::wstring;
+using boost::convert;
+
+struct boost::cnv::by_default : boost::cnv::strtol {};
+
+

+

+

+

+
string const     bad_str = "not an int";
+string const     std_str = "-11";
+char const* const  c_str = "-12";
+boost::string_view v_str = boost::string_view(c_str, 2);
+
+BOOST_TEST( -1 == convert<int>(bad_str).value_or(-1));
+BOOST_TEST(-11 == convert<int>(std_str).value());
+BOOST_TEST(-12 == convert<int>(  c_str).value());
+BOOST_TEST( -1 == convert<int>(  v_str).value_or(0));
+
+

+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support.html b/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support.html new file mode 100644 index 0000000..9508d45 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support.html @@ -0,0 +1,93 @@ + + + +Formatting Support + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +
+ +

+

+
#include <boost/convert.hpp>
+#include <boost/convert/strtol.hpp>
+
+using std::string;
+using std::wstring;
+using boost::convert;
+
+namespace cnv = boost::cnv;
+namespace arg = boost::cnv::parameter;
+
+

+

+

+

+
boost::cnv::strtol cnv;
+
+BOOST_TEST( "11111110" == convert< string>(254, cnv(arg::base = cnv::base::bin)).value());
+BOOST_TEST(      "254" == convert< string>(254, cnv(arg::base = cnv::base::dec)).value());
+BOOST_TEST(       "FE" == convert< string>(254, cnv(arg::base = cnv::base::hex)).value());
+BOOST_TEST(      "376" == convert< string>(254, cnv(arg::base = cnv::base::oct)).value());
+
+

+

+

+

+
BOOST_TEST(L"11111110" == convert<wstring>(254, cnv(arg::base = cnv::base::bin)).value());
+BOOST_TEST(     L"254" == convert<wstring>(254, cnv(arg::base = cnv::base::dec)).value());
+BOOST_TEST(      L"FE" == convert<wstring>(254, cnv(arg::base = cnv::base::hex)).value());
+BOOST_TEST(     L"376" == convert<wstring>(254, cnv(arg::base = cnv::base::oct)).value());
+
+

+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/field_width__fill_character_and_adjustment.html b/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/field_width__fill_character_and_adjustment.html new file mode 100644 index 0000000..8da18f8 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/field_width__fill_character_and_adjustment.html @@ -0,0 +1,74 @@ + + + +Field Width, Fill Character and Adjustment + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+

+
boost::cnv::strtol cnv;
+
+string s01 = convert<string>( 12, cnv(arg::width = 4)).value();
+string s02 = convert<string>( 12, cnv(arg::width = 5)
+                                     (arg::fill = '*')).value();
+string s03 = convert<string>( 12, cnv(arg::width = 5)
+                                     (arg::fill = 'x')
+                                     (arg::adjust = cnv::adjust::left)).value();
+string s04 = convert<string>(-98, cnv(arg::width = 6)
+                                     (arg::fill = 'Z')
+                                     (arg::adjust = cnv::adjust::right)).value();
+
+string s05 = convert<string>(-12.3451, cnv(arg::precision = 2)
+                                          (arg::width = 10)
+                                          (arg::fill = '*')
+                                          (arg::adjust = cnv::adjust::left)).value();
+string s06 = convert<string>(-12.3450, cnv(arg::adjust = cnv::adjust::right)).value();
+string s07 = convert<string>(-12.3450, cnv(arg::adjust = cnv::adjust::center)).value();
+
+BOOST_TEST(s01 == "  12");
+BOOST_TEST(s02 == "***12");
+BOOST_TEST(s03 == "12xxx");
+BOOST_TEST(s04 == "ZZZ-98");
+BOOST_TEST(s05 == "-12.35****");
+BOOST_TEST(s06 == "****-12.35");
+BOOST_TEST(s07 == "**-12.35**");
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/floating_point_precision.html b/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/floating_point_precision.html new file mode 100644 index 0000000..e6abdb6 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/floating_point_precision.html @@ -0,0 +1,57 @@ + + + +Floating-Point Precision + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+

+
boost::cnv::strtol cnv;
+
+BOOST_TEST(  "12.3" == convert<string>(12.3456, cnv(arg::precision = 1)).value());
+BOOST_TEST( "12.35" == convert<string>(12.3456, cnv(arg::precision = 2)).value());
+BOOST_TEST("12.346" == convert<string>(12.3456, cnv(arg::precision = 3)).value());
+
+BOOST_TEST(  "-12.3" == convert<string>(-12.3456, cnv(arg::precision = 1)).value());
+BOOST_TEST( "-12.35" == convert<string>(-12.3456, cnv(arg::precision = 2)).value());
+BOOST_TEST("-12.346" == convert<string>(-12.3456, cnv(arg::precision = 3)).value());
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/leading_whitespace_characters.html b/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/leading_whitespace_characters.html new file mode 100644 index 0000000..07a2479 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/strtol_converter/formatting_support/leading_whitespace_characters.html @@ -0,0 +1,59 @@ + + + +Leading Whitespace Characters + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+

+
boost::cnv::strtol cnv;
+
+BOOST_TEST(-1 == convert<int>( " 12", cnv(arg::skipws = false)).value_or(-1));
+BOOST_TEST(12 == convert<int>( " 12", cnv(arg::skipws =  true)).value_or(-1));
+
+

+

+

+

+
BOOST_TEST(-1 == convert<int>(L" 12", cnv(arg::skipws = false)).value_or(-1));
+BOOST_TEST(12 == convert<int>(L" 12", cnv(arg::skipws =  true)).value_or(-1));
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/strtol_converter/supported_string_types.html b/doc/html/boost_convert/converters_detail/strtol_converter/supported_string_types.html new file mode 100644 index 0000000..a0b0c91 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/strtol_converter/supported_string_types.html @@ -0,0 +1,71 @@ + + + +Supported String Types + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +
+ +

+

+
BOOST_TEST(L"11111110" == convert<wstring>(254, cnv(arg::base = cnv::base::bin)).value());
+BOOST_TEST(     L"254" == convert<wstring>(254, cnv(arg::base = cnv::base::dec)).value());
+BOOST_TEST(      L"FE" == convert<wstring>(254, cnv(arg::base = cnv::base::hex)).value());
+BOOST_TEST(     L"376" == convert<wstring>(254, cnv(arg::base = cnv::base::oct)).value());
+
+

+

+

+

+
BOOST_TEST(-1 == convert<int>(L" 12", cnv(arg::skipws = false)).value_or(-1));
+BOOST_TEST(12 == convert<int>(L" 12", cnv(arg::skipws =  true)).value_or(-1));
+
+

+

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/converters_detail/strtol_converter/supported_string_types/custom_string_types.html b/doc/html/boost_convert/converters_detail/strtol_converter/supported_string_types/custom_string_types.html new file mode 100644 index 0000000..f15b057 --- /dev/null +++ b/doc/html/boost_convert/converters_detail/strtol_converter/supported_string_types/custom_string_types.html @@ -0,0 +1,77 @@ + + + +Custom String Types + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+

+
struct my_string
+{
+    using      this_type = my_string;
+    using     value_type = char;
+    using       iterator = value_type*;
+    using const_iterator = value_type const*;
+
+    my_string ();
+    my_string (const_iterator, const_iterator =0);
+
+    char const*    c_str () const { return storage_; }
+    const_iterator begin () const { return storage_; }
+    const_iterator   end () const { return storage_ + strlen(storage_); }
+    this_type& operator= (char const*);
+
+    private:
+
+    static size_t const size_ = 12;
+    char storage_[size_];
+};
+
+

+

+

+

+
boost::cnv::strtol cnv;
+
+BOOST_TEST(  "12" == convert<my_string>(12, cnv).value());
+BOOST_TEST("0.95" == convert<my_string>(0.95, cnv(arg::precision = 2)).value());
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/default_converter.html b/doc/html/boost_convert/default_converter.html new file mode 100644 index 0000000..f45c299 --- /dev/null +++ b/doc/html/boost_convert/default_converter.html @@ -0,0 +1,118 @@ + + + +Default Converter + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The explicit converter as in +

+
int i = boost::convert<int>("123", converter).value();
+
+

+ 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. +

+
+ + + + + +
[Important]Important

+ There is no default converter set by default. +

+

+ Consequently, without additional configuration steps the following call will + fail to compile: +

+
int i = boost::convert<int>("123").value(); // No converter provided
+
+

+ However, after boost::cnv::by_default + is defined simply as: +

+

+

+
struct boost::cnv::by_default : boost::cnv::cstream {};
+
+

+

+

+ or potentially configured with additional formatting: +

+

+

+
struct boost::cnv::by_default : boost::cnv::cstream
+{
+    by_default() { (*this)(std::uppercase)(std::hex); }
+};
+
+

+

+

+ the code compiles and deploys boost::cnv::cstream when boost::convert() is called without an explicitly supplied + converter: +

+

+

+
// No explicit converter provided. boost::cnv::by_default is used.
+int         i = boost::convert<int>("F").value_or(-1);
+std::string s = boost::convert<std::string>(255).value_or("bad");
+
+// 'i' and 's' are converted using boost::cnv::cstream
+// with std::uppercase and std::hex formatting applied.
+
+BOOST_TEST(i == 15);   // 15(10) = F(16)
+BOOST_TEST(s == "FF"); // 255(10) = FF(16)
+
+

+

+

+ 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. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/design_notes.html b/doc/html/boost_convert/design_notes.html new file mode 100644 index 0000000..a8b7549 --- /dev/null +++ b/doc/html/boost_convert/design_notes.html @@ -0,0 +1,138 @@ + + + +Design Notes + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ "The art of simplicity is a puzzle of + complexity” Doug Horton +

+

+ Feel free to skip this section. It is here to document the process and the + decisions made during design to be able to review and to reevaluate and to + ensure the relevancy and the correctness of those decisions and ultimately + the design. Still, this section might be useful for understanding why and how + certain decisions have been made and why Boost.Convert + is the way it is. +

+
+ +

+ Boost.Convert has been designed to satisfy the following + user requirements: +

+
    +
  1. + (R1) Boost.Convert shall provide + a mechanism and an interface that take a value of type TypeIn + and yield a value of type TypeOut using an algorithm + of type Converter; +
  2. +
  3. + (R2) Boost.Convert shall provide + a mechanism and an interface to indicate success or failure of the requested + conversion; +
  4. +
  5. + (R3) Boost.Convert shall provide + fully-functional interfaces for two different program flows where +
      +
    1. + (R3a) error-processing is orthogonal to the + normal program flow (exception-throwing interface); +
    2. +
    3. + (R3b) normal and error-processing flows are + part of the same program flow (non-throwing interface); +
    4. +
    +
  6. +
  7. + (R4) The throwing interface shall return the result + of successful conversion or shall throw an exception; +
  8. +
  9. + (R5) The non-throwing interface shall return the + result and/or some indication of conversion success or failure; +
      +
    1. + (R5a) there shall be means to distinguish + success from failure; +
    2. +
    3. + (R5b) the result of conversion shall only + be available when conversion succeeds; +
    4. +
    5. + (R5c) when conversion fails, an optional fallback + value shall be returned instead if supplied; +
    6. +
    7. + (R5d) in the case of failure (with no fallback + provided) an attempt to retrieve the result shall result in an + exception thrown; +
    8. +
    +
  10. +
  11. + (R6) Boost.Convert shall provide + a uniform interface suitable for generic programming; +
  12. +
  13. + (R7) Boost.Convert shall not + interfere with or intercept any exceptions that are not part of the official + converter interface (i.e. exceptions caused by malfunction, etc.); +
  14. +
  15. + (R8) Converters shall be independent of and shall + not rely on the Boost.Convert infrastructure. +
  16. +
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/design_notes/converter_signature.html b/doc/html/boost_convert/design_notes/converter_signature.html new file mode 100644 index 0000000..f046cb5 --- /dev/null +++ b/doc/html/boost_convert/design_notes/converter_signature.html @@ -0,0 +1,89 @@ + + + +Converter Signature + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The following converter signatures have been considered: +

+
bool operator()(TypeIn const&, TypeOut&); //#1
+void operator()(TypeIn const&, boost::optional<TypeOut>&); //#2
+boost::optional<TypeOut> operator()(TypeIn const&); //#3
+
+

+ From the design perspective the signature #1 has the advantage of providing + the best separation of concerns. Namely, it leaves the + respective converter with only one task -- the actual task of conversion. + In practice though that can result in unnecessary performance overhead. Namely, + given an instance of TypeOut type is supplied from outside, + a storage for that instance needs to be allocated and, most importantly, + initialized. That initialization phase (which can be expensive) is an unnecessary + overhead as, if the conversion operation succeeds, the initial value is overridden + with the actual result, if it fails, then the value of the TypeOut + instance is either meaningless or worse misleading. +

+

+ The signature #2 avoids the initialization overhead by deploying boost::optional's ability to allocate storage + without initializing it. Now the storage for TypeOut + is still allocated outside but it is not initialized. It is now converter's + responsibility to know how to initialize the TypeOut + instance and, when needed, to actually initialize it. + In practice it is usually easier than it might sound. For example, strtol()-based + converter might have something along the following lines: +

+
void operator()(char const* str_in, boost::optional<int>& result_out) const
+{
+   char const* str_end = str_in + strlen(str_in);
+   char*       cnv_end = 0;
+   long int     result = ::strtol(str_in, &cnv_end, base_);
+
+   if (INT_MIN <= result && result <= INT_MAX && cnv_end == str_end)
+       result_out = int(result);
+}
+
+

+ The signature #3 has been briefly considered as aesthetically advantageous + and more idiomatic. Unfortunately, it lacked automatic deduction of the + TypeOut which, consequently, had to be specified explicitly. + For different types of supported converters (class-based, plain old functions, + lambdas) that complicated considerably the implementation of the Boost.Convert + infrastructure and restricted implementation of the respective converters. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/design_notes/user_interface_signature.html b/doc/html/boost_convert/design_notes/user_interface_signature.html new file mode 100644 index 0000000..4adcfd4 --- /dev/null +++ b/doc/html/boost_convert/design_notes/user_interface_signature.html @@ -0,0 +1,201 @@ + + + +User Interface Signature + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The first attempt to accommodate the User Requirements might result in the + following fairly conventional interface: +

+
template<typename Out, typename In> Out  convert (In const&); //#1
+template<typename Out, typename In> Out  convert (In const&, Out const& fallback); //#2
+template<typename Out, typename In> bool convert (Out& result_out, In const&); //#3
+template<typename Out, typename In> bool convert (Out& result_out, In const&, Out const& fallback); //#4
+
+

+ with the following behavior: +

+
    +
  1. + returns the result or throws on failure (R3a, R4); +
  2. +
  3. + does not throw, returns the result or the provided fallback (R3b, + R5, R5c but not R5a); +
  4. +
  5. + does not throw, writes the result to result_out + (when successful), returns indication of success or failure (R3b, + R5, R5a but not R5c); +
  6. +
  7. + does not throw, writes the result to result_out + (when successful) or the provided fallback, returns indication of success + or failure (R3b, R5, R5c + and R5a). +
  8. +
+

+ The #3 and #4 signatures are special as they, in fact, return two things + -- the actual result (written into the result_out) + and the indication of success or failure (returned by the functions). Given + that a reference to result_out + is passed in, the actual result_out + instance is constructed (storage allocated and initialized) outside the function + calls. +

+

+ Similar to the scenario described in the Converter + Signature section that results in an additional and unnecessary overhead. + Indeed, if the conversion operation succeeds, then the initialization value + is overridden (with the actual result), if it fails, then the value is either + overridden still (with the fallback) or is meaningless. +

+

+ To avoid the overhead we might again (as in the Converter + Signature section) deploy boost::optional + and to change the signatures to +

+
bool convert (boost::optional<Out>&, In const&); //#3
+bool convert (boost::optional<Out>&, In const&, Out const&); //#4
+
+

+ Now, when we look at #3, we can see that the indication of success or failure + is duplicated. Namely, it is returned from the function and is encapsulated + in boost::optional<Out>. + Consequently, #3 can be further simplified to +

+
void convert (boost::optional<Out>&, In const&); //#3
+
+

+ or expressed more idiomatically (in C++) as: +

+
boost::optional<Out> convert (In const&); //#3
+
+

+ So far, we have arrived to the following set +

+
Out                  convert (In const&); //#1
+Out                  convert (In const&, Out const&); //#2
+boost::optional<Out> convert (In const&); //#3
+bool                 convert (boost::optional<Out>&, In const&, Out const&); //#4
+
+

+ which as a whole looks quite ugly and, in fact, does not even compile as + #1 clashes with #3. The good thing though is that functionally + #1 and #2 are not needed anymore as they are duplicates of the following + #3 deployments: +

+
Out out1 = boost::convert(in).value(); // #3 with #1 behavior
+Out out2 = boost::convert(in).value_or(fallback); // #3 with #2 behavior
+
+

+ Again, we are not discussing aesthetic aspects of the interface (or syntactic + sugar some might say, which might be very subjective). Instead, we are focusing + on the functional completeness and so far we manage + to maintain the same functional completeness with less. +

+

+ Turns out, with a bit of effort, we can get away without the most complex + one -- #4 -- as well: +

+
boost::optional<Out> out = boost::convert(in);
+bool         out_success = out ? true : false;
+Out            out_value = out.value_or(fallback);
+
+

+ So, ultimately we arrive to one and only +

+
boost::optional<Out> convert(In const&);
+
+

+ The important qualities of the API are that it is functionally-complete + and the most efficient way to deploy the chosen converter + signature (see the Converter + Signature section). Namely, the boost::convert() interface is routinely optimized out (elided) + when deployed as +

+
boost::optional<Out> out = boost::convert(in);
+
+

+ The API has several deployment-related advantages. First, it says exactly + what it does. Given a conversion request is only a request, + the API returns boost::optional essentially saying "I'll + try but I might fail. Proceed as you find appropriate.". Honest and + simple. I prefer it to "I'll try. I might fail but you do not want to + know about it." or "I'll try. If I fail, you die." or variations + along these lines. :-) +

+

+ On a more serious note though the interface allows for batched conveyor-style + conversions. Namely, attempting to convert several values, in sequence, storing + the boost::optional results and, then, analyzing/validating + them (without losing the information if each individual conversion was successful + or not) in some semi-automated way. +

+

+ Again, that API does not have to be the only API Boost.Convert + provides. However, that API is the only essential API. + Other APIs are relatively easily derived from it. For example, +

+
template<typename Out, typename In>
+Out
+convert(In const& in, Out const& fallback) //#2
+{
+   return convert(in).value_or(fallback);
+}
+
+

+ Given that it is extremely difficult (if not impossible) to come up with + a library API that could please everyone, we might as well settle on the + essential API and let the users build their own APIs + (as in the example above) to satisfy their aesthetic preferences. +

+

+ Still, it needs to be acknowledged that boost::optional + is a fairly new concept and some people are reluctant using it or find its + deployment unreasonably complicating. Consequently, Boost.Convert + provides an alternative (more conventional) interface: +

+
Out convert(In const&, Converter const&, Out const& fallback_value);
+Out convert(In const&, Converter const&, Functor const& fallback_functor);
+Out convert(In const&, Converter const&, boost::throw_on_failure);
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/error_detection.html b/doc/html/boost_convert/error_detection.html new file mode 100644 index 0000000..e29075f --- /dev/null +++ b/doc/html/boost_convert/error_detection.html @@ -0,0 +1,182 @@ + + + +Better Error Detection + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ "Detection is, or ought to be, an exact + science, ..." Sir Arthur Conan Doyle +

+

+

+
int i2 = convert<int>("not an int", cnv).value_or(-1); // after the call i2==-1
+
+if (i2 == -1) process_failure();
+
+

+

+

+ The code above is straightforward and self-explanatory but, strictly speaking, + is not entirely correct as -1 might be the result of a conversion failure or + the successful conversion of the "-1" string. Still, in reality "spare" + values (outside the valid/sensible range) are often available to indicate conversion + failures. If so, such straightorward deployment might be adequate. Alternatively, + it might be not that uncommon to ignore conversion failures altogether and + to simply log the event and to proceed with the supplied fallback value. +

+

+ Applications outside these mentioned categories still require conversion failure + reliably detected and processed accordingly. The boost::lexical_cast's + (only) answer is to throw on failure and Boost.Convert + supports that behavior as well: +

+

+

+
try
+{
+    int i1 = lexical_cast<int>(str);         // Throws if the conversion fails.
+    int i2 = convert<int>(str, cnv).value(); // Throws if the conversion fails.
+}
+catch (...)
+{
+    process_failure();
+}
+
+

+

+

+ However, to cater for a wider range of program-flow variations, Boost.Convert + adds the flexibility of +

+
    +
  • + delaying the moment when the conversion-failure exception is actually thrown + or +
  • +
  • + avoiding the exception altogether. +
  • +
+

+

+
optional<int> r1 = convert<int>(str1, cnv); // Does not throw on conversion failure.
+optional<int> r2 = convert<int>(str2, cnv); // Does not throw on conversion failure.
+// ...
+try // Delayed processing of potential exceptions.
+{
+    int i1 = r1.value(); // Will throw if conversion failed.
+    int i2 = r2.value(); // Will throw if conversion failed.
+}
+catch (boost::bad_optional_access const&)
+{
+    // Handle failed conversion.
+}
+
+// Exceptions are avoided altogether.
+int i1 = r1 ? r1.value() : fallback_value;
+int i2 = r2.value_or(fallback_value);
+int i3 = convert<int>(str3, cnv).value_or(fallback_value);
+int i4 = convert<int>(str3, cnv).value_or_eval(fallback_function);
+
+

+

+

+ Here boost::optional + steps forward as the actual type returned by boost::convert() which until now we avoided by immediately + calling its value-accessor methods: +

+
int i1 = boost::convert<int>(str1, cnv).value();
+int i2 = boost::convert<int>(str2, cnv).value_or(fallback_value);
+int i3 = boost::convert<int>(str3, cnv).value_or_eval(fallback_function);
+
+
+ + + + + +
[Note]Note

+ One notable advantage of value_or_eval() over value_or() is that the actual calculation of the + fallback_value is potentially + delayed and conditional on the success or failure of the conversion. +

+

+ From the user perspective, boost::lexical_cast + processes failure in a somewhat one-dimensional non-negotiable manner. boost::convert + takes a more flexible approach. It provides choice and leaves the decision + to the user. It is not unimaginable that, on the library level, propagating + the conversion-failure exception might be the only available option. On the + application level though, in my personal experience, the choice has overwhelmingly + been to handle conversion failures locally, i.e. avoiding + conversion-failure exception propagation or, better still, avoiding exceptions + altogether with program flows similar to: +

+

+

+
boost::optional<int> res = boost::convert<int>(str, cnv);
+
+if (!res) log("str conversion failed!");
+
+int i1 = res.value_or(fallback_value);
+
+// ...proceed
+
+

+

+

+ and +

+

+

+
struct fallback_func
+{
+    int operator()() const { log("Failed to convert"); return 42; }
+};
+
+

+

+

+

+
// Fallback function is called when failed
+int i2 = convert<int>(str, cnv).value_or_eval(fallback_func());
+int i3 = convert<int>(str, cnv, fallback_func()); // Same as above. Alternative API.
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/getting_started.html b/doc/html/boost_convert/getting_started.html new file mode 100644 index 0000000..46110e2 --- /dev/null +++ b/doc/html/boost_convert/getting_started.html @@ -0,0 +1,143 @@ + + + +Getting Started + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +
+ + + + + +
[Note]Note

+ Given the ubiquity of boost::lexical_cast + and the familiarity of the programming community with it, here and further + in the documentation boost::lexical_cast + is often mentioned as a reference. +

+
+ +

+ For die-hard boost::lexical_cast users or as a transitional + path to boost::convert, one of boost::convert + deployments is not that different from boost::lexical_cast. + In fact, the original boost::lexical_cast + functionality is easily deployed through boost::convert + interface: +

+

+

+
#include <boost/convert.hpp>
+#include <boost/convert/lexical_cast.hpp>
+
+

+

+

+

+
using std::string;
+using boost::lexical_cast;
+using boost::convert;
+
+

+

+

+

+
// Definition of the default converter (optional)
+struct boost::cnv::by_default : boost::cnv::lexical_cast {};
+
+

+

+

+

+
try
+{
+    auto  cnv = boost::cnv::lexical_cast();        // boost::lexical_cast-based converter
+    int    i1 = lexical_cast<int>("123");          // boost::lexical_cast standard deployment
+    int    i2 = convert<int>("123").value();       // boost::convert with the default converter
+    int    i3 = convert<int>("123", cnv).value();  // boost::convert with an explicit converter
+    string s1 = lexical_cast<string>(123);         // boost::lexical_cast standard deployment
+    string s2 = convert<string>(123).value();      // boost::convert with the default converter
+    string s3 = convert<string>(123, cnv).value(); // boost::convert with an explicit converter
+
+    BOOST_TEST(i1 == 123);
+    BOOST_TEST(i2 == 123);
+    BOOST_TEST(i3 == 123);
+    BOOST_TEST(s1 == "123");
+    BOOST_TEST(s2 == "123");
+    BOOST_TEST(s3 == "123");
+}
+catch (std::exception const& ex)
+{
+    // Please be aware that the conversion requests above can fail.
+    // Use try'n'catch blocks to handle any exceptions thrown.
+    // Ignore this at your peril!
+    std::cerr << "Exception " << ex.what() << std::endl;
+}
+
+

+

+
+ + + + + +
[Important]Important

+ As we explore boost::convert behavior and interface further, + at first they might appear unduly complex, verbose, etc... nothing like + atoi()... + so famous for all the wrong reasons. :-) It is important to remember that + a conversion request is only a request which may succeed + but may also fail... which might not be as rare or as exceptional as one + might hope. boost::convert (as well as boost::lexical_cast) + behavior and interfaces reflect that reality. +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/getting_started/basic_conversion_failure_detection.html b/doc/html/boost_convert/getting_started/basic_conversion_failure_detection.html new file mode 100644 index 0000000..923e50a --- /dev/null +++ b/doc/html/boost_convert/getting_started/basic_conversion_failure_detection.html @@ -0,0 +1,168 @@ + + + +Basic Conversion-Failure Detection + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+

+
using std::string;
+using boost::lexical_cast;
+using boost::convert;
+
+

+

+

+

+
boost::cnv::cstream cnv;
+
+int i1 = lexical_cast<int>("123");              // Throws when conversion fails.
+int i2 = convert<int>("123", cnv).value();      // Throws when conversion fails.
+int i3 = convert<int>("uhm", cnv).value_or(-1); // Returns -1 when conversion fails.
+
+BOOST_TEST(i1 == 123);
+BOOST_TEST(i2 == 123);
+BOOST_TEST(i3 == -1);
+
+

+

+

+ The above is translated to English as +

+
    +
  • + "convert a string to int" for i1 and i2 + and +
  • +
  • + "convert a string to int and return -1 if the conversion + fails" for i3. +
  • +
+

+ The i1 and i2 deployments look sufficiently close + and behave identically. Namely, with the user instructions silent about the + conversion failure, those are treated as "exceptional" and throw. +

+

+ The i3 specification, on + the other hand, is explicit about conversion failures. The supplied fallback + value is returned if the requested conversion fails. +

+

+ That basic error detection and processing might be sufficient for a variety + of conversion deployments. For example: +

+

+

+
int i1 = convert<int>(s1, cnv(std::hex)).value_or(-1); // Read as hex
+int i2 = convert<int>(s2, cnv(std::dec)).value_or(-1); // Read as decimal
+
+if (i1 == -1) log("bad i1"), i1 = default_i1; // Log failure. Proceed with the default
+if (i2 == -1) log("bad i2"), i2 = default_i2; // Log failure. Proceed with the default
+
+// ... proceed
+
+

+

+

+ Or +

+

+

+
int
+fallback_fun(char const* msg, int fallback_value)
+{
+    // The principal advantage of a fallback_func over a fallback_value
+    // is that the former is only called when the conversion request fails.
+    // Consequently, the returned fallback_value is only calculated (which
+    // potentially might be expensive) when it is absolutely necessary.
+    log(msg); return fallback_value;
+}
+
+

+

+

+

+
int i1 = convert<int>(s1).value_or_eval(std::bind(fallback_fun, "bad i1", default_i1));
+int i2 = convert<int>(s2).value_or_eval(std::bind(fallback_fun, "bad i2", default_i2));
+// ... proceed
+
+

+

+

+ Or, if we do not care about logging conversion failures: +

+

+

+
int i1 = convert<int>(s1, cnv(std::hex)).value_or(default_i1); // If failed, proceed with the default
+int i2 = convert<int>(s2, cnv(std::dec)).value_or(default_i2); // If failed, proceed with the default
+// ... proceed
+
+

+

+

+ So far the deployment of boost::convert + seems more flexible, more compact and natural (your mileage may vary) and + potentially more efficient compared to boost::lexical_cast + which achieves somewhat similar results with: +

+

+

+
int i1 = default_i1;
+
+try
+{
+    i1 = lexical_cast<int>(str);
+}
+catch (...)
+{
+    log("bad i1");
+}
+
+

+

+

+ By design, this is boost::lexical_cast's + only behavior -- straightforward and comprehensible, but limited. It makes + quite a few legitimate process/program flows difficult and awkward to implement. + Boost.Convert addresses that with additional functionality, + flexibility and convenience. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/getting_started/flexibility_and_adaptability_to_change.html b/doc/html/boost_convert/getting_started/flexibility_and_adaptability_to_change.html new file mode 100644 index 0000000..25a7408 --- /dev/null +++ b/doc/html/boost_convert/getting_started/flexibility_and_adaptability_to_change.html @@ -0,0 +1,128 @@ + + + +Flexibility and Adaptability to Change + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ "There is nothing more constant than + change" Heraclitus +

+

+ Sooner or later (during initial development or in the maintenance phase) + flexibility and adaptability become important. Deployment of Boost.Convert + helps to adjust and to change in line with the evolution of the requirements. + For example, if the program flow would benefit from the non-throwing behavior, + then: +

+

+

+
using std::string;
+using boost::lexical_cast;
+using boost::convert;
+
+

+

+

+

+
// Does not throw. Returns fallback value (-1) when failed.
+int i = convert<int>("uhm", boost::cnv::lexical_cast()).value_or(-1);
+
+BOOST_TEST(i == -1); // Conversion failed. 'i' assigned the fallback value.
+
+

+

+

+ Or, if the component is identified as too slow, then the performance could + be improved with minimal effort by replacing the converter: +

+

+

+
#include <boost/convert/strtol.hpp>
+#include <boost/convert/spirit.hpp>
+
+

+

+

+

+
auto cnv1 = boost::cnv::lexical_cast();
+auto cnv2 = boost::cnv::strtol();
+auto cnv3 = boost::cnv::spirit();
+
+int i1 = convert<int>("123", cnv1).value();
+int i2 = convert<int>("123", cnv2).value(); // Two times faster than lexical_cast.
+int i3 = convert<int>("123", cnv3).value(); // Four times faster than lexical_cast.
+
+

+

+

+ If, instead, the requirements change to support more input formats or to + require a certain output format, then, again, that could be accommodated + with: +

+

+

+
#include <boost/convert/stream.hpp>
+
+

+

+

+

+
try
+{
+    int i1 = lexical_cast<int>("   123"); // Does not work.
+    BOOST_TEST(!"Never reached");
+}
+catch (...) {}
+
+auto        cnv = boost::cnv::cstream();
+int          i2 = convert<int>("   123", cnv(std::skipws)).value(); // Success
+string       s1 = lexical_cast<string>(12.34567);
+string       s2 = convert<string>(12.34567, cnv(std::fixed)(std::setprecision(3))).value();
+string       s3 = convert<string>(12.34567, cnv(std::scientific)(std::setprecision(3))).value();
+string expected = local::is_msc ? "1.235e+001" : "1.235e+01";
+
+BOOST_TEST(i2 == 123);        // boost::cnv::cstream. Successful conversion of "   123".
+BOOST_TEST(s1 == "12.34567"); // boost::lexical_cast. Precision is not configurable.
+BOOST_TEST(s2 == "12.346");   // boost::cnv::cstream. Precision was set to 3. Fixed.
+BOOST_TEST(s3 == expected);   // boost::cnv::cstream. Precision was set to 3. Scientific.
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/integration_of_user_types.html b/doc/html/boost_convert/integration_of_user_types.html new file mode 100644 index 0000000..9fd72ea --- /dev/null +++ b/doc/html/boost_convert/integration_of_user_types.html @@ -0,0 +1,206 @@ + + + +Integration of User-Defined Types + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Probably the most obvious way to support a new type is to write a converter + (potentially by inheriting from an existing converter) that understands the + type and implements whatever transformation functionality is required. That + said, conversions to certain types are very common (for example, string/text-related + conversions) and, consequently, an ability to extend support + of an existing converter onto a user-defined type might + be the preferred option. The obvious example of such design might be the std::iostream + library and its type-integration mechanism based on +

+
std::istream& operator>>(std::istream&, Type&);       // For input
+std::ostream& operator<<(std::ostream&, Type const&); // For output
+
+

+ Within the Boost.Convert framework the integration and + support of user-defined types is every converter's private business. Every + converter is free to implement its own (or re-use an existing) user-type-integration + mechanism. +

+

+ + boost::cnv::stream + et al. +

+

+ Unsurprisingly, the converters based on the std::iostream + library use the mechanism introduced and supported by that library. That is, +

+
    +
  • + for output Type needs to be Output Streamable; +
  • +
  • + for input Type needs to be Input Streamable. +
  • +
+

+ which in practical terms means that the type needs to have the following operators + defined: +

+
std::istream& operator>>(std::istream&, Type&);       // For input
+std::ostream& operator<<(std::ostream&, Type const&); // For output
+
+

+ For example, +

+

+

+
struct change
+{
+    enum value_type { no, up, dn };
+
+    change(value_type v =no) : value_(v) {}
+    bool operator==(change v) const { return value_ == v.value_; }
+    value_type value() const { return value_; }
+
+    private: value_type value_;
+};
+
+

+

+

+

+
std::istream& operator>>(std::istream& stream, change& chg)
+{
+    std::string str; stream >> str;
+
+    /**/ if (str == "up") chg = change::up;
+    else if (str == "dn") chg = change::dn;
+    else if (str == "no") chg = change::no;
+    else stream.setstate(std::ios_base::failbit);
+
+    return stream;
+}
+
+std::ostream& operator<<(std::ostream& stream, change const& chg)
+{
+    return stream << (chg == change::up ? "up" : chg == change::dn ? "dn" : "no");
+}
+
+

+

+

+ That allows handling conversions of user-defined types with std::iostream-based + converters: +

+

+

+
boost::cnv::cstream      cnv1;
+boost::cnv::lexical_cast cnv2;
+
+change chg = change::up;
+string  s1 = convert<string>(chg, cnv1, "bad");                // Input type (change) deduced
+string  s2 = convert<string, change>(change::dn, cnv1, "bad"); // Input type (change) enforced
+
+BOOST_TEST(convert<change>("up", cnv1, change::no) == change::up);
+BOOST_TEST(convert<change>("up", cnv2, change::no) == change::up);
+BOOST_TEST(s1 == "up");
+BOOST_TEST(s2 == "dn");
+
+

+

+

+ + boost::cnv::strtol + et al. +

+

+ Other converters (based on boost::cnv::cnvbase) implement support for user types + similarly but without the std::iostream-related + overhead (see Converters + Compared). Namely, new types are supported by the converters after the + following is defined: +

+
void operator>>(TypeIn const&, boost::optional<TypeOut>&);
+
+

+ For example, the mentioned change + class is deployed with boost::cnv::strol after the following change-to-string + and string-to-change conversions are defined: +

+

+

+
inline void operator>>(change chg, boost::optional<std::string>& str)
+{
+    str = chg == change::up ? "up" : chg == change::dn ? "dn" : "no";
+}
+
+inline void operator>>(std::string const& str, boost::optional<change>& chg)
+{
+    /**/ if (str == "up") chg = change::up;
+    else if (str == "dn") chg = change::dn;
+    else if (str == "no") chg = change::no;
+}
+
+

+

+

+ which are not that dissimilar to (but considerably more efficient than) previously + shown: +

+
std::istream& operator>>(std::istream&, change&);
+std::ostream& operator<<(std::ostream&, change const&);
+
+

+ That allows handling conversions of user-defined types with boost::cnv::strtol: +

+

+

+
boost::cnv::strtol cnv;
+change          up_chg = change::up;
+change          dn_chg = change::dn;
+
+BOOST_TEST(convert<std::string>(up_chg, cnv, "bad") == "up");
+BOOST_TEST(convert<std::string>(dn_chg, cnv, "bad") == "dn");
+BOOST_TEST(convert<std::string>(    12, cnv, "bad") == "12");
+
+BOOST_TEST(convert<change>("up", cnv, change::no) == change::up);
+BOOST_TEST(convert<change>("dn", cnv, change::no) == change::dn);
+BOOST_TEST(convert<   int>("12", cnv, -1) == 12);
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/introduction.html b/doc/html/boost_convert/introduction.html new file mode 100644 index 0000000..6163b47 --- /dev/null +++ b/doc/html/boost_convert/introduction.html @@ -0,0 +1,197 @@ + + + +Introduction + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Boost.Convert builds on the boost::lexical_cast + experience and takes those type conversion/transformation-related ideas further +

+
    +
  • + to be applicable to a wider range of conversion-related deployment scenarios, +
  • +
  • + to provide a more flexible, configurable and extendible type-conversion + framework, +
  • +
  • + to provide generic consistent behavior, +
  • +
  • + to unify and to uniformly deploy various conversion + facilities through one consistent interface. +
  • +
+

+ Boost.Convert provides new and familiar conversion/transformation-related + functionality such as: +

+
    +
  • + means to deploy types that do not meet the Default + Constructibility requirement; +
  • +
  • + four types of the conversion-failure detection: +
      +
    • + as part of the same process flow -- basic and generic; +
    • +
    • + as a branched process flow -- exception-based and function-based; +
    • +
    +
  • +
  • + the choice of immediate or delayed exception-throwing and non-throwing + conversion-failure processing; +
  • +
  • + flexibility of conversion-failure processing via: +
      +
    • + an exception thrown; +
    • +
    • + the fallback value returned; +
    • +
    • + the fallback function called; +
    • +
    +
  • +
  • + support for standard algorithms. +
  • +
+

+ Boost.Convert consists of two components: +

+
    +
  • + the boost::convert() + interface; +
  • +
  • + an extendible collection of pluggable converters. +
  • +
+

+ The boost::convert() + interface +

+
    +
  • + advertises, provides and ensures certain consistent behavior; +
  • +
  • + unifies and provides one consistent interface to various + conversion facilities. +
  • +
+

+ The collection of pluggable converters is independent of the boost::convert() API facade and is designed to be extendible + and extended over time. Currently the following converters are provided: +

+
    +
  • + boost::lexical_cast-based, +
  • +
  • + printf/scanf-based, +
  • +
  • + strtol-inspired, +
  • +
  • + std::stringstream-based, +
  • +
  • + boost::spirit-based. +
  • +
+

+ The converters provide new and familiar functionality and demonstrate how existing + and independent conversion facilities might be incorporated in to the Boost.Convert + framework. For example, the std::stream-based + converter draws on the standard std::streams + functionality and provides: +

+
    +
  • + string-to-type and type-to-string conversions; +
  • +
  • + formatting support (std::ios-based + precision, base, upper/lower-case, scientific, etc.); +
  • +
  • + support for different locales; +
  • +
  • + char and wchar_t + support. +
  • +
+

+ The following code demonstrates conversion of an array of integers from their + textual hexadecimal representation. It assigns -1 to those + which fail to convert: +

+

+

+
std::array<char const*, 3> strs = {{ " 5", "0XF", "not an int" }};
+std::vector<int>           ints;
+boost::cnv::cstream         cnv;
+
+// Configure converter to read hexadecimal, skip (leading) white spaces.
+cnv(std::hex)(std::skipws);
+
+std::transform(strs.begin(), strs.end(), std::back_inserter(ints),
+    boost::cnv::apply<int>(std::cref(cnv)).value_or(-1));
+
+BOOST_TEST(ints.size() == 3); // Number of values processed.
+BOOST_TEST(ints[0] ==  5);    // " 5"
+BOOST_TEST(ints[1] == 15);    // "0XF"
+BOOST_TEST(ints[2] == -1);    // "not an int"
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/other_conversions.html b/doc/html/boost_convert/other_conversions.html new file mode 100644 index 0000000..0c40895 --- /dev/null +++ b/doc/html/boost_convert/other_conversions.html @@ -0,0 +1,72 @@ + + + +Beyond Basic Conversions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ 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. +

+

+ As an experiment, the code below (taken from test/encryption.cpp) + does not do type conversion. Instead, it applies a string transformation: +

+
string encrypted = boost::convert<string>("ABC", my_cypher).value();
+string decrypted = boost::convert<string>(encrypted, my_cypher).value();
+
+BOOST_ASSERT(encrypted == "123");
+BOOST_ASSERT(decrypted == "ABC");
+
+

+ The original "ABC" string is "encrypted" as "123" + first and then "123" is "decrypted" back to its original + "ABC" form. +

+

+ Similarly, I personally do not immediately see as objectionable string-transformations + like: +

+
std::u8string utf8 = boost::convert<std::u8string>(utf32_str, cnv);
+std::u8string utf8 = boost::convert<std::u8string>(mbcs_str, cnv);
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/performance.html b/doc/html/boost_convert/performance.html new file mode 100644 index 0000000..0f28e2a --- /dev/null +++ b/doc/html/boost_convert/performance.html @@ -0,0 +1,139 @@ + + + +Performance + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +
+ +

+ The performance of Boost.Convert depends entirely on + the performance of the converter deployed. A few converters have been tested + for string conversions to basic types and to a user-defined type. +

+

+ In turn, the performance of every particular converter depends on the platform, + the compiler used and the particular implementation of the underlying conversion + component (std::stream, printf, + Boost.Spirit, etc.). Consequently, the results below + are only an approximate indication of relative performance + of the mentioned converters on the tested platforms. +

+

+ When compiled with gcc-5.4.0 on 64-bit Ubuntu 16.04, tests produced the following + results: +

+
str-to-int: spirit/strtol/lcast/scanf/stream= 0.27/ 0.35/  0.92/  2.11/  2.09 seconds.
+str-to-lng: spirit/strtol/lcast/scanf/stream= 0.69/ 0.31/  1.28/  2.07/  2.50 seconds.
+str-to-dbl: spirit/strtol/lcast/scanf/stream= 0.73/ 1.06/  7.95/  2.87/  5.10 seconds.
+int-to-str: spirit/strtol/lcast/prntf/stream= 1.96/ 1.39/  2.52/  3.49/  2.58 seconds.
+lng-to-str: spirit/strtol/lcast/prntf/stream= 2.45/ 1.51/  2.32/  3.30/  2.63 seconds.
+dbl-to-str: spirit/strtol/lcast/prntf/stream= 6.62/ 4.46/ 28.69/ 20.60/ 14.16 seconds.
+
+

+ Based on the results, all things considered, I tend to conclude that there + is no clear winner: +

+
    +
  • + the Spirit.Qi-based converter was the fastest for + string to basic (int, double) conversions. So, it might be a + good candidate for the tasks predominantly doing that kind of conversions + (with Spirit.Qi conversion-related limitations in + mind); Spirit.Karma's to-string + performance did not seem as impressive; +
  • +
  • + the std::iostream-based converter was comparatively + slow. Still, given its maturity, availability and formatting support, + it might be an option to consider if conversion performance is not your + primary concern; +
  • +
  • + the strtol-inspired converter + was reasonably fast and with formatting support might be an attractive + all-rounder. It should be noted that it is nowhere as mature as boost::cnv::lexical_cast or boost::cnv::stream. + So, bugs are to be expected. +
  • +
+

+ For user-defined types cnv::lexical_cast, + cnv::cstream and cnv::strtol + were tested with the following results: +

+
str-to-user-type: lcast/stream/strtol=0.36/0.18/0.07 seconds.
+user-type-to-str: lcast/stream/strtol=0.58/0.09/0.06 seconds.
+
+

+ To provide string-to-user-type and user-type-to-string + conversions the first two deploy the same standard std::iostream + library. However, boost::cnv::cstream + considerably outperforms boost::lexical_cast + in these tests. The results reflect different underlying designs. Namely, + the standard Boost.Convert deployment pattern is to + create a converter or converters once and then re-use them. boost::lexical_cast, on the other hand, creates + and then destroys a std::stream instance every time the function + is called and the boost::lexical_cast performance table + indicates that the "std::stringstream with construction" + operation is considerably more expensive compared to "std::stringstream + without construction". +

+

+ boost::cnv::strtol + support for user types has been implemented similarly but without the std::stream-related + overhead. That resulted in the best out-of-three performance results. +

+

+ Based on the performance data, I tend to conclude that, given type-safety + and benefits provided by the Boost.Convert framework, + it (with appropriate converters) should probably be the first choice for + conversion-related tasks. +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/performance/boost_convert_overhead.html b/doc/html/boost_convert/performance/boost_convert_overhead.html new file mode 100644 index 0000000..a38abe4 --- /dev/null +++ b/doc/html/boost_convert/performance/boost_convert_overhead.html @@ -0,0 +1,118 @@ + + + +Boost.Convert Overhead + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Boost.Convert framework adds an additional layer of + indirection and some Boost.Convert converters are wrappers + around actual conversion facilities such as boost::lexical_cast, + boost::spirit, etc. Consequently, there might + be reasonable concerns with regard to the performance overhead introduced + by the framework as opposed to deploying conversion facilities directly. +

+

+ To test that code has been borrowed and adapted from the Spirit.Qi performance/optimization + framework (see $BOOST_ROOT/libs/spirit/workbench/qi/int_parser.cpp). The + tests were +

+
    +
  1. + compiled using gcc-4.6.3 and gcc-4.8.2; +
  2. +
  3. + with optimization: g++ -O3 + test/performance_spirit.cpp -Iinclude -I../boost_1_56_0 -lrt; +
  4. +
  5. + on 64-bit Ubuntu 12.04 and 32-bit Ubuntu 14.04; +
  6. +
  7. + run against the input of randomly generated 18 numeric strings (9 positive + and 9 negative numbers with the number of digits from 1 to 9); +
  8. +
  9. + run for +
      +
    • + boost::lexical_cast and boost::lexical_cast-based converter; +
    • +
    • + boost::spirit::qi::parse and boost::spirit::qi::parse-based + converter. +
    • +
    +
  10. +
+

+ The purpose of the test was to deploy the same functionality directly and + as part of the Boost.Convert framework. Results are + shown below for several consecutive runs: +

+
gcc-4.6.3 (64-bit)
+raw_lxcast_str_to_int_test: 1.0504170070 [s]
+cnv_lxcast_str_to_int_test: 1.0610595810 [s] (1% slower than raw above)
+raw_spirit_str_to_int_test: 0.2845369110 [s]
+cnv_spirit_str_to_int_test: 0.2834834560 [s] (1% faster than raw above)
+
+raw_lxcast_str_to_int_test: 1.0770350390 [s] (2% slower than prev. run)
+cnv_lxcast_str_to_int_test: 1.0607665160 [s] (1% faster than raw above)
+raw_spirit_str_to_int_test: 0.2792295470 [s] (2% faster than prev. run)
+cnv_spirit_str_to_int_test: 0.2827574570 [s] (1% slower than raw above)
+
+gcc-4.8.2 (32-bit)
+raw_lxcast_str_to_int_test: 8.5153330600 [s]
+cnv_lxcast_str_to_int_test: 8.6989499850 [s] (2% slower than raw above)
+raw_spirit_str_to_int_test: 2.4197476510 [s]
+cnv_spirit_str_to_int_test: 2.4594171510 [s] (2% slower than raw above)
+
+raw_lxcast_str_to_int_test: 8.4136546980 [s] (1% faster than prev. run)
+cnv_lxcast_str_to_int_test: 8.5322524600 [s] (1% slower than raw above)
+raw_spirit_str_to_int_test: 2.3842388060 [s] (1% faster than prev. run)
+cnv_spirit_str_to_int_test: 2.3812094400 [s] (0% faster than raw above)
+
+

+ The results for consecutive runs varied with deviations of around 2%. Under + 2% was also the deviation of the "cnv" code compared to the "raw" + code. That indicates that the Boost.Convert framework + had no detectable running overhead with the tested compilers, hardware and + deployment scenarios. The results might be different on other platforms. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/performance/the_bigger_picture.html b/doc/html/boost_convert/performance/the_bigger_picture.html new file mode 100644 index 0000000..69c231b --- /dev/null +++ b/doc/html/boost_convert/performance/the_bigger_picture.html @@ -0,0 +1,118 @@ + + + +The Bigger Picture + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The presented conversion-related performance data (and potential performance-related + concerns) have to be taken in perspective. A special project with serious + high performance requirements is most likely to require special solutions + which are most likely to cast out many generic libraries. Still, the existence + of such projects did not kill or diminish in any way the importance of generic + libraries. And Boost.Convert is one such generic + library. +

+

+ More so, if performance is a concern, then, in all likelihood, for the great + majority of the mainstream projects Boost.Convert will + be far from the top on the performance profiler's list. For example, to measure + conversion-related overhead relative to std::string-related + overhead, std::string was replaced with a custom small-string + type: +

+

+

+
struct my_string
+{
+    using      this_type = my_string;
+    using     value_type = char;
+    using       iterator = value_type*;
+    using const_iterator = value_type const*;
+
+    my_string ();
+    my_string (const_iterator, const_iterator =0);
+
+    char const*    c_str () const { return storage_; }
+    const_iterator begin () const { return storage_; }
+    const_iterator   end () const { return storage_ + strlen(storage_); }
+    this_type& operator= (char const*);
+
+    private:
+
+    static size_t const size_ = 12;
+    char storage_[size_];
+};
+
+

+

+

+ The class above is essentially a glorified 12-bytes character buffer sufficient + to accommodate string representations of 32-bit integers. Deployed with the + same converters and the same algorithms: +

+

+

+
printf("strtol int-to std::string/small-string: %.2f/%.2f seconds.\n",
+       local::to_str<std::string, int>(boost::cnv::strtol()),
+       local::to_str<  my_string, int>(boost::cnv::strtol()));
+printf("spirit int-to std::string/small-string: %.2f/%.2f seconds.\n",
+       local::to_str<std::string, int>(boost::cnv::spirit()),
+       local::to_str<  my_string, int>(boost::cnv::spirit()));
+printf("stream int-to std::string/small-string: %.2f/%.2f seconds.\n",
+       local::to_str<std::string, int>(boost::cnv::cstream()),
+       local::to_str<  my_string, int>(boost::cnv::cstream()));
+
+

+

+

+ It produced the following relative results (compiled with gcc + -O3): +

+
strtol int-to std::string/small-string: 1.41/0.53 seconds.
+spirit int-to std::string/small-string: 1.98/1.04 seconds.
+stream int-to std::string/small-string: 2.49/1.40 seconds.
+
+

+ The results suggest that for the projects that deal with string-related conversions + and routinely deploy std::string + facilities the conversion-related overhead will be outweighed by the overhead + of std::string-related operations. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/supported_compilers.html b/doc/html/boost_convert/supported_compilers.html new file mode 100644 index 0000000..cfabb82 --- /dev/null +++ b/doc/html/boost_convert/supported_compilers.html @@ -0,0 +1,73 @@ + + + +Supported Compilers + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ Boost.Convert makes use of SFINAE for correct boost::convert() deployment depending on the context. Unfortunately, + the correctness and the completeness of SFINAE support varies with different + compilers and different versions of those compilers. Consequently, some compilers + fail to compile Boost.Convert API (although the actual + functionality provided by the converters themselves is probably availabable + via other non-standard means). Boost.Convert has been + tested through the Boost regression-testing framework with the following results: +

+
    +
  • + CLANG. Successfully tested with versions from 2.9 to 3.6; +
  • +
  • + GCC. Successfully tested with versions from 4.2.1 through to 5.0. Earlier + versions were not tested; +
  • +
  • + Intel C++ compiler. Successfully tested with versions from 12.1 forward. + Earlier versions fail to compile Boost.Convert due + to lacking full SFINAE support; +
  • +
  • + MSVC. Successfully tested from MSVC 2013 (msvc-12.0) forward. Earlier versions + had some components disabled due to lacking full SFINAE support; +
  • +
+

+ Please visit Boost.Convert + regression test summary for the latest available report. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/supporting_tools.html b/doc/html/boost_convert/supporting_tools.html new file mode 100644 index 0000000..8eb2be1 --- /dev/null +++ b/doc/html/boost_convert/supporting_tools.html @@ -0,0 +1,73 @@ + + + +Supporting Tools + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ + +

+ This section describes a few supporting tools written as part of Boost.Convert + but which might be useful in their own rights. +

+
+ +

+ boost::cnv::range is a consolidation of the [begin, + end)-based ranges (such as std::string) and the sentry-based + ranges (such as null-terminated C-style strings). It allows universal traversal + of both types of ranges with +

+
for (auto s = range.begin(); s != range.sentry(); ++s)
+
+

+ without the penalty or the need for an extra traversal of the sentry-based + ranges in order to find the end. +

+

+ TODO +

+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/supporting_tools/boost__cnv__is_cnv.html b/doc/html/boost_convert/supporting_tools/boost__cnv__is_cnv.html new file mode 100644 index 0000000..e4a1a06 --- /dev/null +++ b/doc/html/boost_convert/supporting_tools/boost__cnv__is_cnv.html @@ -0,0 +1,45 @@ + + + +boost::cnv::is_cnv + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ TODO +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/supporting_tools/boost__cnv__is_range.html b/doc/html/boost_convert/supporting_tools/boost__cnv__is_range.html new file mode 100644 index 0000000..3d4fea6 --- /dev/null +++ b/doc/html/boost_convert/supporting_tools/boost__cnv__is_range.html @@ -0,0 +1,45 @@ + + + +boost::cnv::is_range + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ TODO +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/supporting_tools/boost_declare_has_member.html b/doc/html/boost_convert/supporting_tools/boost_declare_has_member.html new file mode 100644 index 0000000..b12418f --- /dev/null +++ b/doc/html/boost_convert/supporting_tools/boost_declare_has_member.html @@ -0,0 +1,91 @@ + + + +BOOST_DECLARE_HAS_MEMBER + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The BOOST_DECLARE_HAS_MEMBER macro allows to declare a trait which would + then let introspect the existence of a class member (a data member or a member + function) with the specified name. +

+

+ For example, the following declarations introduce local::has_begin + and local::has_funop traits which then allow to test + if the supplied class has respectively begin + and operator() + members: +

+

+

+
namespace { namespace local
+{
+    BOOST_DECLARE_HAS_MEMBER(has_begin, begin);
+    BOOST_DECLARE_HAS_MEMBER(has_funop, operator());
+}}
+
+

+

+

+ Now these traits can be used as follows: +

+

+

+
namespace { namespace local
+{
+    struct test01 { int   begin; };
+    struct test02 { char* begin() { return 0; } };
+    struct test22 { void operator()() {} };
+}}
+
+

+

+

+

+
BOOST_TEST(local::has_begin<local::test01>::value == true);
+BOOST_TEST(local::has_begin<local::test02>::value == true);
+BOOST_TEST(local::has_funop<local::test22>::value == true);
+
+

+

+

+ As it can be seen from the example the traits only check for the existence + of a member (be that a data member or a member function) with the specified + name. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert/supporting_tools/boost_declare_is_callable.html b/doc/html/boost_convert/supporting_tools/boost_declare_is_callable.html new file mode 100644 index 0000000..30b2fe4 --- /dev/null +++ b/doc/html/boost_convert/supporting_tools/boost_declare_is_callable.html @@ -0,0 +1,130 @@ + + + +BOOST_DECLARE_IS_CALLABLE + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ The BOOST_DECLARE_IS_CALLABLE macro extends the functionality provided by + BOOST_DECLARE_HAS_MEMBER and allows to declare a trait which would then let + introspect the existence of a named class member function callable + with the supplied signature. +

+

+ For example, the following declarations introduce local::can_call_funop + and local::can_call_func traits: +

+

+

+
namespace { namespace local
+{
+    BOOST_DECLARE_IS_CALLABLE(can_call_funop, operator());
+    BOOST_DECLARE_IS_CALLABLE(can_call_func, func);
+}}
+
+

+

+

+ The traits allow to test if the supplied class has respectively operator() + and func() + member functions callable with the specified signature: +

+

+

+
namespace { namespace callable
+{
+    struct  test1 { int  operator()(double, std::string) { return 0; }};
+    struct  test2 { void operator()(double, std::string) {}};
+    struct  test3 { void operator()(int) {}};
+    struct  test4 { std::string operator()(int) const { return std::string(); }};
+    struct  test5 { std::string operator()(int, std::string const& =std::string()) const { return std::string(); }};
+    struct  test6 { template<typename T> std::string operator()(T) const { return std::string(); }};
+    struct  test7 { template<typename T> T operator()(T) const  { return T(); }};
+
+    struct  test11 { int  func(double, std::string) { return 0; }};
+    struct  test12 { void func(double, std::string) {}};
+    struct  test13 { void func(int) {}};
+    struct  test14 { std::string func(int) const { return std::string(); }};
+    struct  test15 { std::string func(int, std::string const& =std::string()) const { return std::string(); }};
+    struct  test16 { template<typename T> std::string func(T) const { return std::string(); }};
+    struct  test17 { template<typename T> T func(T) const { return T(); }};
+}}
+
+

+

+

+

+
BOOST_TEST((local::can_call_funop<callable::test1, int (double, std::string)>::value == true));
+BOOST_TEST((local::can_call_funop<callable::test1, double (int, std::string)>::value == true));
+BOOST_TEST((local::can_call_funop<callable::test1, void (double, std::string)>::value == true));
+BOOST_TEST((local::can_call_funop<callable::test1, void (int, std::string)>::value == true));
+BOOST_TEST((local::can_call_funop<callable::test1, void (int, char const*)>::value == true));
+BOOST_TEST((local::can_call_funop<callable::test1, int (double, int)>::value == false));
+BOOST_TEST((local::can_call_funop<callable::test1, int (double)>::value == false));
+
+BOOST_TEST((local::can_call_funop<callable::test2, int  (double, std::string)>::value == false));
+BOOST_TEST((local::can_call_funop<callable::test2, void (double, std::string)>::value == true));
+BOOST_TEST((local::can_call_funop<callable::test2, void (   int, std::string)>::value == true));
+BOOST_TEST((local::can_call_funop<callable::test2, void (   int, char const*)>::value == true));
+
+

+

+

+

+
BOOST_TEST((local::can_call_func<callable::test11, int (double, std::string)>::value == true));
+BOOST_TEST((local::can_call_func<callable::test11, double (int, std::string)>::value == true));
+BOOST_TEST((local::can_call_func<callable::test11, void (double, std::string)>::value == true));
+BOOST_TEST((local::can_call_func<callable::test11, void (int, std::string)>::value == true));
+BOOST_TEST((local::can_call_func<callable::test11, void (int, char const*)>::value == true));
+BOOST_TEST((local::can_call_func<callable::test11, int (double, int)>::value == false));
+BOOST_TEST((local::can_call_func<callable::test11, int (double)>::value == false));
+
+BOOST_TEST((local::can_call_func<callable::test12, int  (double, std::string)>::value == false));
+BOOST_TEST((local::can_call_func<callable::test12, void (double, std::string)>::value == true));
+BOOST_TEST((local::can_call_func<callable::test12, void (   int, std::string)>::value == true));
+BOOST_TEST((local::can_call_func<callable::test12, void (   int, char const*)>::value == true));
+
+

+

+

+ As it can be seen from the example the traits check for the existence of + a callable member function but not necessarily + of the specified signature. Please check the Boost.TTI + library for the latter. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_convert_c___reference.html b/doc/html/boost_convert_c___reference.html new file mode 100644 index 0000000..fecc8f5 --- /dev/null +++ b/doc/html/boost_convert_c___reference.html @@ -0,0 +1,97 @@ + + + +Boost.Convert C++ Reference + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+Boost.Convert C++ Reference

+ +
+ +
namespace boost {
+  unspecified throw_on_failure;
+  template<typename TypeOut, typename TypeIn, typename Converter> 
+    boost::optional< TypeOut > convert(TypeIn const &, Converter const &);
+  template<typename TypeOut, typename TypeIn> 
+    boost::optional< TypeOut > convert(TypeIn const &);
+
+  // Boost.Convert non-optional deployment interface. 
+  template<typename TypeOut, typename TypeIn, typename Converter> 
+    TypeOut convert(TypeIn const & value_in, Converter const & converter, 
+                    unspecified);
+  template<typename TypeOut, typename TypeIn, typename Converter, 
+           typename Fallback> 
+    enable_if< is_convertible< Fallback, TypeOut >, TypeOut >::type 
+    convert(TypeIn const & value_in, Converter const & converter, 
+            Fallback const & fallback);
+  template<typename TypeOut, typename TypeIn, typename Converter, 
+           typename Fallback> 
+    enable_if< cnv::is_fun< Fallback, TypeOut >, TypeOut >::type 
+    convert(TypeIn const & value_in, Converter const & converter, 
+            Fallback fallback);
+  namespace cnv {
+    template<typename Converter, typename TypeOut, typename TypeIn> 
+      struct reference;
+
+    template<typename Converter, typename TypeOut> 
+      struct reference<Converter, TypeOut, void>;
+    template<typename TypeOut, typename TypeIn, typename Converter> 
+      reference< Converter, TypeOut, TypeIn > apply(Converter const &);
+    template<typename TypeOut, typename Converter> 
+      reference< Converter, TypeOut, void > apply(Converter const & cnv);
+  }
+}
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/header/boost/convert/base_hpp.html b/doc/html/header/boost/convert/base_hpp.html new file mode 100644 index 0000000..e543e50 --- /dev/null +++ b/doc/html/header/boost/convert/base_hpp.html @@ -0,0 +1,51 @@ + + + +Header <boost/convert/base.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+
+BOOST_CNV_TO_STRING
+BOOST_CNV_STRING_TO
+BOOST_CNV_PARAM(param_name, param_type)
+
namespace boost {
+  namespace cnv {
+    template<typename derived_type> struct cnvbase;
+  }
+}
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/header/boost/convert/lexical_cast_hpp.html b/doc/html/header/boost/convert/lexical_cast_hpp.html new file mode 100644 index 0000000..3e5354c --- /dev/null +++ b/doc/html/header/boost/convert/lexical_cast_hpp.html @@ -0,0 +1,46 @@ + + + +Header <boost/convert/lexical_cast.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
namespace boost {
+  namespace cnv {
+    struct lexical_cast;
+  }
+}
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/header/boost/convert/parameters_hpp.html b/doc/html/header/boost/convert/parameters_hpp.html new file mode 100644 index 0000000..9f00af2 --- /dev/null +++ b/doc/html/header/boost/convert/parameters_hpp.html @@ -0,0 +1,53 @@ + + + +Header <boost/convert/parameters.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
namespace boost {
+  namespace cnv {
+
+    enum adjust { left, right, center };
+
+    enum base { bin = =2, oct = =8, dec = =10, hex = =16 };
+
+    enum notation { fixed, scientific };
+    namespace parameter {
+    }
+  }
+}
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/header/boost/convert/printf_hpp.html b/doc/html/header/boost/convert/printf_hpp.html new file mode 100644 index 0000000..f8e3e4a --- /dev/null +++ b/doc/html/header/boost/convert/printf_hpp.html @@ -0,0 +1,46 @@ + + + +Header <boost/convert/printf.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
namespace boost {
+  namespace cnv {
+    struct printf;
+  }
+}
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/header/boost/convert/spirit_hpp.html b/doc/html/header/boost/convert/spirit_hpp.html new file mode 100644 index 0000000..ab1a9b1 --- /dev/null +++ b/doc/html/header/boost/convert/spirit_hpp.html @@ -0,0 +1,46 @@ + + + +Header <boost/convert/spirit.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
namespace boost {
+  namespace cnv {
+    struct spirit;
+  }
+}
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/header/boost/convert/stream_hpp.html b/doc/html/header/boost/convert/stream_hpp.html new file mode 100644 index 0000000..a329a9f --- /dev/null +++ b/doc/html/header/boost/convert/stream_hpp.html @@ -0,0 +1,53 @@ + + + +Header <boost/convert/stream.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+
+BOOST_CNV_STRING_ENABLE
+BOOST_CNV_PARAM(PARAM_NAME, PARAM_TYPE)
+
namespace boost {
+  namespace cnv {
+    template<typename Char> struct basic_stream;
+
+    typedef boost::cnv::basic_stream< char > cstream;
+    typedef boost::cnv::basic_stream< wchar_t > wstream;
+  }
+}
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/header/boost/convert/strtol_hpp.html b/doc/html/header/boost/convert/strtol_hpp.html new file mode 100644 index 0000000..7267916 --- /dev/null +++ b/doc/html/header/boost/convert/strtol_hpp.html @@ -0,0 +1,46 @@ + + + +Header <boost/convert/strtol.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
namespace boost {
+  namespace cnv {
+    struct strtol;
+  }
+}
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/header/boost/make_default_hpp.html b/doc/html/header/boost/make_default_hpp.html new file mode 100644 index 0000000..0ed247d --- /dev/null +++ b/doc/html/header/boost/make_default_hpp.html @@ -0,0 +1,44 @@ + + + +Header <boost/make_default.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
namespace boost {
+  template<typename T> T make_default();
+}
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/index.html b/doc/html/index.html new file mode 100644 index 0000000..0d83f2c --- /dev/null +++ b/doc/html/index.html @@ -0,0 +1,230 @@ + + + +Chapter 1. Boost.Convert 2.0 + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
Next
+
+
+

+Chapter 1. Boost.Convert 2.0

+

+Vladimir Batov +

+
+
+

+ Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. +

+
+
+
+

Table of Contents

+
+
Rationale
+
Introduction
+
Getting Started
+
+
Basic + Deployment
+
Flexibility + and Adaptability to Change
+
Basic + Conversion-Failure Detection
+
+
Better Error Detection
+
Default Converter
+
Alternative Interface
+
Converters
+
Integration of + User-Defined Types
+
Boost.Convert with Standard Algorithms
+
Performance
+
+
Converters + Compared
+
Boost.Convert + Overhead
+
The Bigger + Picture
+
+
Beyond Basic Conversions
+
Converters in Detail
+
+
boost::cnv::lexical_cast + Converter
+
boost::cnv::stream + Converter
+
+
Formatting + Support
+
+
Numeric + Base
+
Field + Width, Fill Character and Adjustment
+
Leading + Whitespace Characters
+
Format + of Boolean Values
+
+
Locale + Support
+
Supported + String Types
+
+
Wide + String
+
Custom + String Types
+
+
The + Default Constructible Type Requirement
+
+
boost::cnv::strtol + Converter
+
+
Basic + Deployment
+
Formatting + Support
+
+
Numeric + Base (bin, oct, dec, hex)
+
Field + Width, Fill Character and Adjustment
+
Leading + Whitespace Characters
+
Floating-Point + Precision
+
+
Supported + String Types
+
+
Wide + String
+
Custom + String Types
+
+
+
+
Design + Notes
+
+
Requirements
+
Converter + Signature
+
User + Interface Signature
+
+
Supporting Tools
+
+
boost::cnv::range
+
boost::cnv::is_range
+
BOOST_DECLARE_HAS_MEMBER
+
BOOST_DECLARE_IS_CALLABLE
+
boost::cnv::is_cnv
+
+
Supported Compilers
+
Acknowledgements
+
Boost.Convert C++ Reference
+
+
Header <boost/convert.hpp>
+
+
Header <boost/convert/base.hpp>
+
+
Header <boost/convert/lexical_cast.hpp>
+
+
Header <boost/convert/parameters.hpp>
+
Header <boost/convert/printf.hpp>
+
+
Header <boost/convert/spirit.hpp>
+
+
Header <boost/convert/stream.hpp>
+
+
Header <boost/convert/strtol.hpp>
+
+
Header <boost/make_default.hpp>
+
+
+
Index
+
+
+
+ + + + + +
[Important]Important

+ Requires C++11 and up. +

+
+ +

+ I was using textual configuration files extensively and was also processing + and preparing considerable amounts of data in XML. Consequently, I had a need + for an extendible library that would provide a uniform + interface to convert various data between their internal binary representations + and external (predominantly textual) representations. +

+

+ The boost::lexical_cast library (with its orthogonal + and extendible design) looked very promising compared to others (see The String Formatters of Manor + Farm by H. Sutter for the discussion of alternatives). Unfortunately, +

+
    +
  • + many deployed user types simply did not meet boost::lexical_cast + requirements (namely, Default + Constructibility); +
  • +
  • + failure to convert a user-provided configuration parameter was not that + rare or exceptional to justify the hassle and the overhead of exception + processing; consequently, additional flexibility (if, + when and how) in handling conversion + failures was needed; +
  • +
  • + additional conversion-related functionality (such as formatting and locale + support) were needed. +
  • +
+

+ The original hope was to see boost::lexical_cast + extended to be applicable to a wider range of deployment scenarios. However, + after discussions with Kevlin Henney (the boost::lexical_cast + author) and in the Boost Developers forum it was collectively decided that + the desired extensions were not compatible with the original design and the + idea of what boost::lexical_cast embodied and, therefore, a new + component with richer interface and functionality was needed. That decision + resulted in the development of Boost.Convert described + in this document. +

+
+
+ + + +

Last revised: September 13, 2020 at 05:15:28 GMT

+
+
Next
+ + diff --git a/doc/html/index/s18.html b/doc/html/index/s18.html new file mode 100644 index 0000000..c1adc44 --- /dev/null +++ b/doc/html/index/s18.html @@ -0,0 +1,853 @@ + + + +Index + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHome +
+
+

+Index

+

A B C D E F G H I L M N O P R S T U V W

+
+
+A +
+
+
+B +
+
+
+C +
+
+
+D +
+
+
+E +
+
+
+F +
+
+
+G +
+
+
+H +
+
+
+I +
+
+
+L +
+
+
+M +
+
+
+N +
+
    +
  • +

    Numeric Base

    +
    +
  • +
  • +

    Numeric Base (bin, oct, dec, hex)

    +
    +
  • +
+
+O +
+
+
+P +
+
+
+R +
+
+
+S +
+
+
+T +
+
+
+U +
+
  • +

    User Interface Signature

    + +
+
+V +
+
+
+W +
+
+
+
+ + + +
+
+
+PrevUpHome +
+ + diff --git a/doc/html/standalone_HTML.manifest b/doc/html/standalone_HTML.manifest new file mode 100644 index 0000000..d0de180 --- /dev/null +++ b/doc/html/standalone_HTML.manifest @@ -0,0 +1,68 @@ +index.html +boost_convert/introduction.html +boost_convert/getting_started.html +boost_convert/getting_started/flexibility_and_adaptability_to_change.html +boost_convert/getting_started/basic_conversion_failure_detection.html +boost_convert/error_detection.html +boost_convert/default_converter.html +boost_convert/alternative_interface.html +boost_convert/converters.html +boost_convert/integration_of_user_types.html +boost_convert/algorithms.html +boost_convert/performance.html +boost_convert/performance/boost_convert_overhead.html +boost_convert/performance/the_bigger_picture.html +boost_convert/other_conversions.html +boost_convert/converters_detail.html +boost_convert/converters_detail/stream_converter.html +boost_convert/converters_detail/stream_converter/locale_support.html +boost_convert/converters_detail/stream_converter/supported_string_types.html +boost_convert/converters_detail/stream_converter/supported_string_types/custom_string_types.html +boost_convert/converters_detail/stream_converter/the___default_constructible__type_requirement.html +boost_convert/converters_detail/strtol_converter.html +boost_convert/converters_detail/strtol_converter/formatting_support.html +boost_convert/converters_detail/strtol_converter/formatting_support/field_width__fill_character_and_adjustment.html +boost_convert/converters_detail/strtol_converter/formatting_support/leading_whitespace_characters.html +boost_convert/converters_detail/strtol_converter/formatting_support/floating_point_precision.html +boost_convert/converters_detail/strtol_converter/supported_string_types.html +boost_convert/converters_detail/strtol_converter/supported_string_types/custom_string_types.html +boost_convert/design_notes.html +boost_convert/design_notes/converter_signature.html +boost_convert/design_notes/user_interface_signature.html +boost_convert/supporting_tools.html +boost_convert/supporting_tools/boost__cnv__is_range.html +boost_convert/supporting_tools/boost_declare_has_member.html +boost_convert/supporting_tools/boost_declare_is_callable.html +boost_convert/supporting_tools/boost__cnv__is_cnv.html +boost_convert/supported_compilers.html +boost_convert/acknowledgements.html +boost_convert_c___reference.html +boost/cnv/reference.html +boost/cnv/reference_Convert_idm10581.html +boost/cnv/apply_idm10607.html +boost/throw_on_failure.html +boost/convert_idm10633.html +boost/convert_idm10653.html +header/boost/convert/base_hpp.html +boost/cnv/cnvbase.html +BOOST_CNV_TO_STRING.html +BOOST_CNV_STRING_TO.html +BOOST_CNV_PARAM_idm10945.html +header/boost/convert/lexical_cast_hpp.html +boost/cnv/lexical_cast.html +header/boost/convert/parameters_hpp.html +header/boost/convert/printf_hpp.html +boost/cnv/printf.html +header/boost/convert/spirit_hpp.html +boost/cnv/spirit.html +header/boost/convert/stream_hpp.html +boost/cnv/basic_stream.html +boost/cnv/basic_stream/ibuffer_type.html +boost/cnv/basic_stream/obuffer_type.html +BOOST_CNV_STRING_ENABLE.html +BOOST_CNV_PARAM_idm11244.html +header/boost/convert/strtol_hpp.html +boost/cnv/strtol.html +header/boost/make_default_hpp.html +boost/make_default.html +index/s18.html diff --git a/doc/index.idx b/doc/index.idx index 9a54d02..c0ece1b 100644 --- a/doc/index.idx +++ b/doc/index.idx @@ -1,16 +1,16 @@ #index.idx for Convert Quickbook, Doxygen and Auto-index. -# Copyright (c) Vladimir Batov 2009-2014 +# Copyright (c) Vladimir Batov 2009-2020 # Distributed under the Boost Software License, Version 1.0. # See copy at http://www.boost.org/LICENSE_1_0.txt. -!scan ../include/boost/convert/lexical_cast.hpp -!scan ../include/boost/convert/parameters.hpp -!scan ../include/boost/convert/printf.hpp -!scan ../include/boost/convert/spirit.hpp -!scan ../include/boost/convert/stream.hpp -!scan ../include/boost/convert/strtol.hpp -!scan ../include/boost/make_default.hpp -!scan ../include/boost/convert.hpp +!scan ../../../boost/convert/lexical_cast.hpp +!scan ../../../boost/convert/parameters.hpp +!scan ../../../boost/convert/printf.hpp +!scan ../../../boost/convert/spirit.hpp +!scan ../../../boost/convert/stream.hpp +!scan ../../../boost/convert/strtol.hpp +!scan ../../../boost/make_default.hpp +!scan ../../../boost/convert.hpp #!scan "../example" ".*.cpp" true diff --git a/doc/introduction.qbk b/doc/introduction.qbk index 28ce71c..c2232af 100644 --- a/doc/introduction.qbk +++ b/doc/introduction.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/jamfile.v2 b/doc/jamfile.v2 index 79cf0ca..a182ef4 100644 --- a/doc/jamfile.v2 +++ b/doc/jamfile.v2 @@ -1,11 +1,12 @@ # Convert documentation Jamfile -# Copyright (c) Vladimir Batov 2009-2014 +# Copyright (c) Vladimir Batov 2009-2020 # Distributed under the Boost Software License, Version 1.0. # See copy at http://www.boost.org/LICENSE_1_0.txt. using quickbook ; using doxygen ; +using boostbook ; path-constant here : . ; # convenient to refer to files in the same directory as this jamfile.v2 path-constant boost-images : ../../../doc/src/images ; @@ -35,7 +36,7 @@ else doxygen convert_reference : - [ glob $(here)/../include/boost/convert.hpp $(here)/../include/boost/make_default.hpp $(here)/../include/boost/convert/*.hpp ] + [ glob $(here)/../../../boost/convert.hpp $(here)/../../../boost/make_default.hpp $(here)/../../../boost/convert/*.hpp ] : PROJECT_NAME="CONVERT" PROJECT_NUMBER=3 diff --git a/doc/lexcast_converter.qbk b/doc/lexcast_converter.qbk index 7a2fdc3..7b140c5 100644 --- a/doc/lexcast_converter.qbk +++ b/doc/lexcast_converter.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/limitations.qbk b/doc/limitations.qbk index 102a627..2e240af 100644 --- a/doc/limitations.qbk +++ b/doc/limitations.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/no_optional_interface.qbk b/doc/no_optional_interface.qbk index ac03f9d..d21877d 100644 --- a/doc/no_optional_interface.qbk +++ b/doc/no_optional_interface.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/other.qbk b/doc/other.qbk index df9e797..48c91bf 100644 --- a/doc/other.qbk +++ b/doc/other.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/performance.qbk b/doc/performance.qbk index 6e118a8..0b044ed 100644 --- a/doc/performance.qbk +++ b/doc/performance.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/rationale.qbk b/doc/rationale.qbk index 003f66f..f8aa262 100644 --- a/doc/rationale.qbk +++ b/doc/rationale.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/section-end.qbk b/doc/section-end.qbk index 934fc18..f8b47c7 100644 --- a/doc/section-end.qbk +++ b/doc/section-end.qbk @@ -1,7 +1,7 @@ [endsect] [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/stream_converter.qbk b/doc/stream_converter.qbk index 6817c50..1d91c8a 100644 --- a/doc/stream_converter.qbk +++ b/doc/stream_converter.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/strtol_converter.qbk b/doc/strtol_converter.qbk index 10d1463..8fbc3f6 100644 --- a/doc/strtol_converter.qbk +++ b/doc/strtol_converter.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/tools.qbk b/doc/tools.qbk index 5b4da2e..b24151d 100644 --- a/doc/tools.qbk +++ b/doc/tools.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/doc/user_types.qbk b/doc/user_types.qbk index 5bf2088..f42dbb7 100644 --- a/doc/user_types.qbk +++ b/doc/user_types.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) Vladimir Batov 2009-2016 + Copyright (c) Vladimir Batov 2009-2020 Distributed under the Boost Software License, Version 1.0. See copy at http://www.boost.org/LICENSE_1_0.txt. ] diff --git a/example/algorithms.cpp b/example/algorithms.cpp index 6235fbf..66215b2 100644 --- a/example/algorithms.cpp +++ b/example/algorithms.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -6,9 +6,9 @@ #include #include #include -#include -#include +#include #include +#include using std::string; @@ -22,15 +22,15 @@ introduction() representation. It assigns -1 to those which fail to convert: */ - boost::array strs = {{ " 5", "0XF", "not an int" }}; - std::vector ints; - boost::cnv::cstream cnv; + std::array strs = {{ " 5", "0XF", "not an int" }}; + std::vector ints; + boost::cnv::cstream cnv; // Configure converter to read hexadecimal, skip (leading) white spaces. cnv(std::hex)(std::skipws); std::transform(strs.begin(), strs.end(), std::back_inserter(ints), - boost::cnv::apply(boost::cref(cnv)).value_or(-1)); + boost::cnv::apply(std::cref(cnv)).value_or(-1)); BOOST_TEST(ints.size() == 3); // Number of values processed. BOOST_TEST(ints[0] == 5); // " 5" @@ -48,13 +48,13 @@ example1() has been developed) to convert a few `string`s to `int`s with `boost::lexical_cast`: */ - boost::array strs = {{ " 5", "0XF", "not an int" }}; - std::vector ints; + std::array strs = {{ " 5", "0XF", "not an int" }}; + std::vector ints; try { std::transform(strs.begin(), strs.end(), std::back_inserter(ints), - boost::bind(boost::lexical_cast, _1)); + std::bind(boost::lexical_cast, std::placeholders::_1)); BOOST_TEST(0 && "Never reached!"); } @@ -73,8 +73,8 @@ example2() /*`If the exception-throwing behavior is the desired behavior, then ['Boost.Convert] supports that. In addition, it also supports a non-throwing process-flow: */ - boost::array strs = {{ " 5", "0XF", "not an int" }}; - std::vector ints; + std::array strs = {{ " 5", "0XF", "not an int" }}; + std::vector ints; std::transform(strs.begin(), strs.end(), std::back_inserter(ints), boost::cnv::apply(boost::cnv::lexical_cast()).value_or(-1)); @@ -95,14 +95,14 @@ example3() better results with exception-throwing and non-throwing process-flows still supported: */ - boost::array strs = {{ " 5", "0XF", "not an int" }}; - std::vector ints; - boost::cnv::cstream cnv; + std::array strs = {{ " 5", "0XF", "not an int" }}; + std::vector ints; + boost::cnv::cstream cnv; try { std::transform(strs.begin(), strs.end(), std::back_inserter(ints), - boost::cnv::apply(boost::cref(cnv(std::hex)(std::skipws)))); + boost::cnv::apply(std::cref(cnv(std::hex)(std::skipws)))); BOOST_TEST(0 && "Never reached!"); } @@ -121,14 +121,14 @@ static void example4() { - boost::array strs = {{ " 5", "0XF", "not an int" }}; - std::vector ints; - boost::cnv::cstream cnv; + std::array strs = {{ " 5", "0XF", "not an int" }}; + std::vector ints; + boost::cnv::cstream cnv; //[algorithm_example4 std::transform(strs.begin(), strs.end(), std::back_inserter(ints), - boost::cnv::apply(boost::cref(cnv(std::hex)(std::skipws))).value_or(-1)); + boost::cnv::apply(std::cref(cnv(std::hex)(std::skipws))).value_or(-1)); BOOST_TEST(ints.size() == 3); BOOST_TEST(ints[0] == 5); @@ -136,14 +136,14 @@ example4() BOOST_TEST(ints[2] == -1); // Failed conversion /*`[important One notable difference in the deployment of `boost::cnv::cstream` with algorithms is - the use of `boost::cref` (or `std::cref` in C++11). + the use of `std::cref`. It needs to be remembered that with standard algorithms the deployed converter needs to be [@http://en.cppreference.com/w/cpp/named_req/TriviallyCopyable copyable] or [@http://en.cppreference.com/w/cpp/named_req/MoveAssignable movable (C++11)] and is, in fact, copied or moved by the respective algorithm before being used. Given that `std::cstringstream` is not copyable, `boost::cnv::cstream` is not copyable either. - That limitation is routinely worked-around using `boost::ref` or `boost::cref`.] + That limitation is routinely worked-around using `std::ref` or `std::cref`.] */ //] } @@ -156,14 +156,14 @@ example5() /*`And now an example of algorithm-based integer-to-string formatted conversion with `std::hex`, `std::uppercase` and `std::showbase` formatting applied: */ - boost::array ints = {{ 15, 16, 17 }}; + std::array ints = {{ 15, 16, 17 }}; std::vector strs; boost::cnv::cstream cnv; cnv(std::hex)(std::uppercase)(std::showbase); std::transform(ints.begin(), ints.end(), std::back_inserter(strs), - boost::cnv::apply(boost::cref(cnv))); + boost::cnv::apply(std::cref(cnv))); BOOST_TEST(strs.size() == 3); BOOST_TEST(strs[0] == "0XF"); // 15 diff --git a/example/default_converter.cpp b/example/default_converter.cpp index fdcee84..99ef261 100644 --- a/example/default_converter.cpp +++ b/example/default_converter.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/example/default_converter_fail.cpp b/example/default_converter_fail.cpp index 9663996..c7035c4 100644 --- a/example/default_converter_fail.cpp +++ b/example/default_converter_fail.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/example/getting_serious.cpp b/example/getting_serious.cpp index 1e0b759..38f56ae 100644 --- a/example/getting_serious.cpp +++ b/example/getting_serious.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/example/getting_started.cpp b/example/getting_started.cpp index 5fa9c53..186bb5d 100644 --- a/example/getting_started.cpp +++ b/example/getting_started.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -18,8 +18,8 @@ namespace { namespace local #endif }} -#include #include +#include static void @@ -50,8 +50,7 @@ getting_started_example1() //[getting_started_example1 try { - boost::cnv::lexical_cast cnv; // boost::lexical_cast-based converter - + auto cnv = boost::cnv::lexical_cast(); // boost::lexical_cast-based converter int i1 = lexical_cast("123"); // boost::lexical_cast standard deployment int i2 = convert("123").value(); // boost::convert with the default converter int i3 = convert("123", cnv).value(); // boost::convert with an explicit converter @@ -98,9 +97,9 @@ void getting_started_example3() { //[getting_started_example3 - boost::cnv::lexical_cast cnv1; - boost::cnv::strtol cnv2; - boost::cnv::spirit cnv3; + auto cnv1 = boost::cnv::lexical_cast(); + auto cnv2 = boost::cnv::strtol(); + auto cnv3 = boost::cnv::spirit(); int i1 = convert("123", cnv1).value(); int i2 = convert("123", cnv2).value(); // Two times faster than lexical_cast. @@ -117,8 +116,6 @@ void getting_started_example4() { //[getting_started_example4 - boost::cnv::cstream cnv; - try { int i1 = lexical_cast(" 123"); // Does not work. @@ -126,6 +123,7 @@ getting_started_example4() } catch (...) {} + auto cnv = boost::cnv::cstream(); int i2 = convert(" 123", cnv(std::skipws)).value(); // Success string s1 = lexical_cast(12.34567); string s2 = convert(12.34567, cnv(std::fixed)(std::setprecision(3))).value(); @@ -160,11 +158,11 @@ static void getting_started_example6() { - std::string const s1 = "123"; - std::string const s2 = "456"; - int const default_i1 = 11; - int const default_i2 = 12; - boost::cnv::cstream cnv; + std::string s1 = "123"; + std::string s2 = "456"; + int default_i1 = 11; + int default_i2 = 12; + auto cnv = boost::cnv::cstream(); //[getting_started_example6 @@ -184,11 +182,11 @@ static void getting_started_example7() { - std::string const s1 = "123"; - std::string const s2 = "456"; - int const default_i1 = 11; - int const default_i2 = 12; - boost::cnv::cstream cnv; + std::string s1 = "123"; + std::string s2 = "456"; + int default_i1 = 11; + int default_i2 = 12; + auto cnv = boost::cnv::cstream(); //[getting_started_example7 @@ -222,8 +220,8 @@ getting_started_example9() int const default_i2 = 12; //[getting_started_example9 - int i1 = convert(s1).value_or_eval(boost::bind(fallback_fun, "bad i1", default_i1)); - int i2 = convert(s2).value_or_eval(boost::bind(fallback_fun, "bad i2", default_i2)); + int i1 = convert(s1).value_or_eval(std::bind(fallback_fun, "bad i1", default_i1)); + int i2 = convert(s2).value_or_eval(std::bind(fallback_fun, "bad i2", default_i2)); // ... proceed //] BOOST_TEST(i1 == 123); diff --git a/example/lexical_cast.cpp b/example/lexical_cast.cpp index 5527cf1..4e638bc 100644 --- a/example/lexical_cast.cpp +++ b/example/lexical_cast.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/example/stream.cpp b/example/stream.cpp index 0a22c23..25e6eba 100644 --- a/example/stream.cpp +++ b/example/stream.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert.hpp b/include/boost/convert.hpp index efde44f..4e9670e 100644 --- a/include/boost/convert.hpp +++ b/include/boost/convert.hpp @@ -1,6 +1,6 @@ /// @file // Boost.Convert -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // // Many thanks to Julian Gonggrijp, Rob Stewart, Andrzej Krzemienski, Matus Chochlik, Jeroen Habraken, // Hartmut Kaiser, Joel De Guzman, Thijs (M.A.) van den Berg, Roland Bock, Gavin Lambert, Paul Bristow, @@ -127,11 +127,8 @@ namespace boost { namespace cnv { typedef reference this_type; - reference(Converter const& cnv) : converter_(cnv) {} - -#ifdef BOOST_CONVERT_CXX11 - reference(Converter&& cnv) : converter_(std::move(cnv)) {} -#endif + reference (Converter const& cnv) : converter_(cnv) {} + reference (Converter&& cnv) : converter_(std::move(cnv)) {} this_type& value_or(TypeOut const& fallback) @@ -156,11 +153,8 @@ namespace boost { namespace cnv { typedef reference this_type; - reference(Converter const& cnv) : converter_(cnv) {} - -#ifdef BOOST_CONVERT_CXX11 - reference(Converter&& cnv) : converter_(std::move(cnv)) {} -#endif + reference (Converter const& cnv) : converter_(cnv) {} + reference (Converter&& cnv) : converter_(std::move(cnv)) {} this_type& value_or(TypeOut const& fallback) @@ -185,9 +179,9 @@ namespace boost { namespace cnv /// @brief Boost.Convert deployment interface with algorithms /// @details For example, /// @code - /// boost::array strs = {{ " 5", "0XF", "not an int" }}; - /// std::vector ints; - /// boost::cnv::cstream cnv; + /// std::array strs = {{ " 5", "0XF", "not an int" }}; + /// std::vector ints; + /// boost::cnv::cstream cnv; /// /// cnv(std::hex)(std::skipws); /// @@ -195,7 +189,7 @@ namespace boost { namespace cnv /// strs.begin(), /// strs.end(), /// std::back_inserter(ints), - /// boost::cnv::apply(boost::cref(cnv)).value_or(-1)); + /// boost::cnv::apply(std::cref(cnv)).value_or(-1)); /// @endcode template diff --git a/include/boost/convert/base.hpp b/include/boost/convert/base.hpp index 791dbe0..e3d4d19 100644 --- a/include/boost/convert/base.hpp +++ b/include/boost/convert/base.hpp @@ -1,9 +1,9 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. -#ifndef BOOST_CONVERT_CONVERTER_BASE_HPP -#define BOOST_CONVERT_CONVERTER_BASE_HPP +#ifndef BOOST_CONVERT_BASE_HPP +#define BOOST_CONVERT_BASE_HPP #include #include @@ -11,8 +11,6 @@ namespace boost { namespace cnv { - namespace ARG = boost::cnv::parameter; - template struct cnvbase; }} @@ -26,8 +24,19 @@ namespace boost { namespace cnv typename boost::enable_if, void>::type \ operator() -#define BOOST_CNV_PARAM(param_name, param_type) \ - derived_type& operator()(boost::parameter::aux::tag::type const& arg) +#define BOOST_CNV_PARAM_SET(param_name) \ + template \ + void set_( \ + argument_pack const& arg, \ + cnv::parameter::type::param_name, \ + mpl::true_) + +#define BOOST_CNV_PARAM_TRY(param_name) \ + this->set_( \ + arg, \ + cnv::parameter::type::param_name(), \ + typename mpl::has_key< \ + argument_pack, cnv::parameter::type::param_name>::type()); template struct boost::cnv::cnvbase @@ -77,15 +86,21 @@ struct boost::cnv::cnvbase BOOST_CNV_STRING_TO (string_type const& s, optional< flt_type>& r) const { str_to_(s, r); } BOOST_CNV_STRING_TO (string_type const& s, optional< dbl_type>& r) const { str_to_(s, r); } BOOST_CNV_STRING_TO (string_type const& s, optional< ldbl_type>& r) const { str_to_(s, r); } - // Formatters -// BOOST_CNV_PARAM (locale, std::locale) { locale_ = arg[ARG:: locale]; return dncast(); } - BOOST_CNV_PARAM (base, cnv::base) { base_ = arg[ARG:: base]; return dncast(); } - BOOST_CNV_PARAM (adjust, cnv::adjust) { adjust_ = arg[ARG:: adjust]; return dncast(); } - BOOST_CNV_PARAM (precision, int) { precision_ = arg[ARG::precision]; return dncast(); } - BOOST_CNV_PARAM (uppercase, bool) { uppercase_ = arg[ARG::uppercase]; return dncast(); } - BOOST_CNV_PARAM (skipws, bool) { skipws_ = arg[ARG:: skipws]; return dncast(); } - BOOST_CNV_PARAM (width, int) { width_ = arg[ARG:: width]; return dncast(); } - BOOST_CNV_PARAM (fill, char) { fill_ = arg[ARG:: fill]; return dncast(); } + + template + derived_type& operator()(argument_pack const& arg) + { + BOOST_CNV_PARAM_TRY(base); + BOOST_CNV_PARAM_TRY(adjust); + BOOST_CNV_PARAM_TRY(precision); + BOOST_CNV_PARAM_TRY(uppercase); + BOOST_CNV_PARAM_TRY(skipws); + BOOST_CNV_PARAM_TRY(width); + BOOST_CNV_PARAM_TRY(fill); +// BOOST_CNV_PARAM_TRY(locale); + + return this->dncast(); + } protected: @@ -158,21 +173,36 @@ struct boost::cnv::cnvbase derived_type const& dncast () const { return *static_cast(this); } derived_type& dncast () { return *static_cast(this); } + template + void set_(argument_pack const&, keyword_tag, mpl::false_) {} + + // Formatters + BOOST_CNV_PARAM_SET(base) { base_ = arg[cnv::parameter:: base]; } + BOOST_CNV_PARAM_SET(adjust) { adjust_ = arg[cnv::parameter:: adjust]; } + BOOST_CNV_PARAM_SET(precision) { precision_ = arg[cnv::parameter::precision]; } + BOOST_CNV_PARAM_SET(uppercase) { uppercase_ = arg[cnv::parameter::uppercase]; } + BOOST_CNV_PARAM_SET(skipws) { skipws_ = arg[cnv::parameter:: skipws]; } + BOOST_CNV_PARAM_SET(width) { width_ = arg[cnv::parameter:: width]; } + BOOST_CNV_PARAM_SET(fill) { fill_ = arg[cnv::parameter:: fill]; } +// BOOST_CNV_PARAM_SET(locale) { locale_ = arg[cnv::parameter:: locale]; } + // ULONG_MAX(8 bytes) = 18446744073709551615 (20(10) or 32(2) characters) // double (8 bytes) max is 316 chars - static int const bufsize_ = 512; - bool skipws_; - int precision_; - bool uppercase_; - int width_; - int fill_; - cnv::base base_; - cnv::adjust adjust_; -// std::locale locale_; + static int constexpr bufsize_ = 512; + + bool skipws_; + int precision_; + bool uppercase_; + int width_; + int fill_; + cnv::base base_; + cnv::adjust adjust_; +// std::locale locale_; }; #undef BOOST_CNV_TO_STRING #undef BOOST_CNV_STRING_TO -#undef BOOST_CNV_PARAM +#undef BOOST_CNV_PARAM_SET +#undef BOOST_CNV_PARAM_TRY -#endif // BOOST_CONVERT_CONVERTER_BASE_HPP +#endif // BOOST_CONVERT_BASE_HPP diff --git a/include/boost/convert/detail/char.hpp b/include/boost/convert/detail/char.hpp index a829dc8..7726f96 100644 --- a/include/boost/convert/detail/char.hpp +++ b/include/boost/convert/detail/char.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/detail/config.hpp b/include/boost/convert/detail/config.hpp index 6c74cd3..95bac9b 100644 --- a/include/boost/convert/detail/config.hpp +++ b/include/boost/convert/detail/config.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -9,12 +9,6 @@ #include #include -#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -#undef BOOST_CONVERT_CXX11 -#else -#define BOOST_CONVERT_CXX11 -#endif - // Intel 12.0 and lower have broken SFINAE #if defined(BOOST_INTEL) && (BOOST_INTEL <= 1200) # define BOOST_CONVERT_IS_NOT_SUPPORTED diff --git a/include/boost/convert/detail/has_member.hpp b/include/boost/convert/detail/has_member.hpp index 2cd617f..d0dc9f9 100644 --- a/include/boost/convert/detail/has_member.hpp +++ b/include/boost/convert/detail/has_member.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/detail/is_callable.hpp b/include/boost/convert/detail/is_callable.hpp index 838c248..84f2364 100644 --- a/include/boost/convert/detail/is_callable.hpp +++ b/include/boost/convert/detail/is_callable.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/detail/is_converter.hpp b/include/boost/convert/detail/is_converter.hpp index 6964655..5e85cd7 100644 --- a/include/boost/convert/detail/is_converter.hpp +++ b/include/boost/convert/detail/is_converter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/detail/is_fun.hpp b/include/boost/convert/detail/is_fun.hpp index 72a7681..d8ecc11 100644 --- a/include/boost/convert/detail/is_fun.hpp +++ b/include/boost/convert/detail/is_fun.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/detail/is_string.hpp b/include/boost/convert/detail/is_string.hpp index 75d565e..662ef22 100644 --- a/include/boost/convert/detail/is_string.hpp +++ b/include/boost/convert/detail/is_string.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/detail/range.hpp b/include/boost/convert/detail/range.hpp index 4279a59..cad368d 100644 --- a/include/boost/convert/detail/range.hpp +++ b/include/boost/convert/detail/range.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/lexical_cast.hpp b/include/boost/convert/lexical_cast.hpp index 49b96a1..742e8b3 100644 --- a/include/boost/convert/lexical_cast.hpp +++ b/include/boost/convert/lexical_cast.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/parameters.hpp b/include/boost/convert/parameters.hpp index 21a1376..1f4c28f 100644 --- a/include/boost/convert/parameters.hpp +++ b/include/boost/convert/parameters.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -6,6 +6,8 @@ #define BOOST_CONVERT_PARAMETERS_HPP #include +#include +#include namespace boost { namespace cnv { @@ -23,6 +25,7 @@ namespace boost { namespace cnv BOOST_PARAMETER_NAME((precision, type) precision) BOOST_PARAMETER_NAME(( skipws, type) skipws) BOOST_PARAMETER_NAME((uppercase, type) uppercase) + BOOST_PARAMETER_NAME((lowercase, type) lowercase) BOOST_PARAMETER_NAME(( width, type) width) } }} diff --git a/include/boost/convert/printf.hpp b/include/boost/convert/printf.hpp index e206349..00fa2e8 100644 --- a/include/boost/convert/printf.hpp +++ b/include/boost/convert/printf.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/spirit.hpp b/include/boost/convert/spirit.hpp index b33a793..93340d4 100644 --- a/include/boost/convert/spirit.hpp +++ b/include/boost/convert/spirit.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/include/boost/convert/stream.hpp b/include/boost/convert/stream.hpp index 17ad2b6..d38512f 100644 --- a/include/boost/convert/stream.hpp +++ b/include/boost/convert/stream.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -17,9 +17,19 @@ typename boost::enable_if, void>::type \ operator() -#define BOOST_CNV_PARAM(PARAM_NAME, PARAM_TYPE) \ - this_type& \ - operator()(boost::parameter::aux::tag::type const& arg) +#define BOOST_CNV_PARAM_SET(param_name) \ + template \ + void set_( \ + argument_pack const& arg, \ + cnv::parameter::type::param_name, \ + mpl::true_) + +#define BOOST_CNV_PARAM_TRY(param_name) \ + this->set_( \ + arg, \ + cnv::parameter::type::param_name(), \ + typename mpl::has_key< \ + argument_pack, cnv::parameter::type::param_name>::type()); namespace boost { namespace cnv { @@ -71,49 +81,67 @@ struct boost::cnv::basic_stream : boost::noncopyable }; basic_stream() : stream_(std::ios_base::in | std::ios_base::out) {} -#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) basic_stream(this_type&& other) : stream_(std::move(other.stream_)) {} -#endif BOOST_CNV_STRING_ENABLE(type const& v, optional& s) const { to_str(v, s); } BOOST_CNV_STRING_ENABLE(string_type const& s, optional& r) const { str_to(cnv::range(s), r); } + // Resolve ambiguity of string-to-string template void operator()( char_type const* s, optional& r) const { str_to(cnv::range< char_type const*>(s), r); } template void operator()(stdstr_type const& s, optional& r) const { str_to(cnv::range(s), r); } // Formatters template - this_type& operator() (manipulator m) { return (stream_ << m, *this); } + typename boost::disable_if, this_type&>::type + operator()(manipulator m) { return (this->stream_ << m, *this); } + this_type& operator() (manipulator_type m) { return (m(stream_), *this); } this_type& operator() (std::locale const& l) { return (stream_.imbue(l), *this); } - BOOST_CNV_PARAM(locale, std::locale) { return (stream_.imbue(arg[cnv::parameter::locale]), *this); } - BOOST_CNV_PARAM(precision, int) { return (stream_.precision(arg[cnv::parameter::precision]), *this); } - BOOST_CNV_PARAM(width, int) { return (stream_.width(arg[cnv::parameter::width]), *this); } - BOOST_CNV_PARAM(fill, char) { return (stream_.fill(arg[cnv::parameter::fill]), *this); } - BOOST_CNV_PARAM(uppercase, bool) + template + typename boost::enable_if, this_type&>::type + operator()(argument_pack const& arg) + { + BOOST_CNV_PARAM_TRY(precision); + BOOST_CNV_PARAM_TRY(width); + BOOST_CNV_PARAM_TRY(fill); + BOOST_CNV_PARAM_TRY(uppercase); + BOOST_CNV_PARAM_TRY(skipws); + BOOST_CNV_PARAM_TRY(adjust); + BOOST_CNV_PARAM_TRY(base); + BOOST_CNV_PARAM_TRY(notation); + + return *this; + } + + private: + + template + void set_(argument_pack const&, keyword_tag, mpl::false_) {} + + BOOST_CNV_PARAM_SET (locale) { stream_.imbue(arg[cnv::parameter::locale]); } + BOOST_CNV_PARAM_SET (precision) { stream_.precision(arg[cnv::parameter::precision]); } + BOOST_CNV_PARAM_SET (width) { stream_.width(arg[cnv::parameter::width]); } + BOOST_CNV_PARAM_SET (fill) { stream_.fill(arg[cnv::parameter::fill]); } + BOOST_CNV_PARAM_SET (uppercase) { bool uppercase = arg[cnv::parameter::uppercase]; uppercase ? (void) stream_.setf(std::ios::uppercase) : stream_.unsetf(std::ios::uppercase); - return *this; } - BOOST_CNV_PARAM(skipws, bool) + BOOST_CNV_PARAM_SET (skipws) { bool skipws = arg[cnv::parameter::skipws]; skipws ? (void) stream_.setf(std::ios::skipws) : stream_.unsetf(std::ios::skipws); - return *this; } - BOOST_CNV_PARAM(adjust, boost::cnv::adjust) + BOOST_CNV_PARAM_SET (adjust) { cnv::adjust adjust = arg[cnv::parameter::adjust]; /**/ if (adjust == cnv::adjust:: left) stream_.setf(std::ios::adjustfield, std::ios:: left); else if (adjust == cnv::adjust::right) stream_.setf(std::ios::adjustfield, std::ios::right); else BOOST_ASSERT(!"Not implemented"); - - return *this; } - BOOST_CNV_PARAM(base, boost::cnv::base) + BOOST_CNV_PARAM_SET (base) { cnv::base base = arg[cnv::parameter::base]; @@ -121,22 +149,16 @@ struct boost::cnv::basic_stream : boost::noncopyable else if (base == cnv::base::hex) std::hex(stream_); else if (base == cnv::base::oct) std::oct(stream_); else BOOST_ASSERT(!"Not implemented"); - - return *this; } - BOOST_CNV_PARAM(notation, boost::cnv::notation) + BOOST_CNV_PARAM_SET (notation) { cnv::notation notation = arg[cnv::parameter::notation]; /**/ if (notation == cnv::notation:: fixed) std::fixed(stream_); else if (notation == cnv::notation::scientific) std::scientific(stream_); else BOOST_ASSERT(!"Not implemented"); - - return *this; } - private: - template void str_to(cnv::range, optional&) const; template void to_str(in_type const&, optional&) const; @@ -193,6 +215,7 @@ boost::cnv::basic_stream::str_to( } #undef BOOST_CNV_STRING_ENABLE -#undef BOOST_CNV_PARAM +#undef BOOST_CNV_PARAM_SET +#undef BOOST_CNV_PARAM_TRY #endif // BOOST_CONVERT_STRINGSTREAM_BASED_CONVERTER_HPP diff --git a/include/boost/convert/strtol.hpp b/include/boost/convert/strtol.hpp index a762bba..9c36df8 100644 --- a/include/boost/convert/strtol.hpp +++ b/include/boost/convert/strtol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -14,13 +14,6 @@ #include #include -#if __GNUC__ == 4 && __GNUC_MINOR__ <= 2 -namespace std -{ - using ::strtold; // Tests indicated that gcc-4.2.1 does not have 'std::strtold' -} -#endif - namespace boost { namespace cnv { struct strtol; diff --git a/include/boost/make_default.hpp b/include/boost/make_default.hpp index e653ef0..641ffd6 100644 --- a/include/boost/make_default.hpp +++ b/include/boost/make_default.hpp @@ -1,5 +1,5 @@ /// @file -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/index.html b/index.html index 6cc92f7..915f25b 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@

Automatic redirection failed, please go to doc/html/index.html

-

Copyright Vladimir Batov 2009-2016

+

Copyright Vladimir Batov 2009-2020

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt). diff --git a/makefile b/makefile index 98d6983..92c6fe0 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ BOOST_ROOT = $(PRJROOT)/boost -cflags = -O3 -I./include -I$(BOOST_ROOT) -Wno-unused-variable -Wno-uninitialized -Wno-deprecated-declarations -lflags = -L$(BOOST_ROOT)/stage/lib -lboost_timer -lboost_chrono -lboost_system +cflags := -O3 -I./include -I$(BOOST_ROOT) -Wno-unused-variable -Wno-uninitialized -Wno-deprecated-declarations +lflags := -L$(BOOST_ROOT)/stage/lib -lboost_timer -lboost_chrono -lboost_system target_1 = convert-test-callable test/callable.cpp target_2 = convert-test-is-converter test/is_converter.cpp diff --git a/test/callable.cpp b/test/callable.cpp index b8f3614..0c986b3 100644 --- a/test/callable.cpp +++ b/test/callable.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -12,8 +12,7 @@ int main(int, char const* []) { return 0; } #include #include #include -#include -#include +#include using std::string; using boost::convert; @@ -73,7 +72,7 @@ template<> void double_only::operator()(double, boost::optional& int main(int, char const* []) { - typedef boost::function&)> boost_func; + typedef std::function&)> boost_func; char const* const str = "-12"; @@ -81,13 +80,13 @@ main(int, char const* []) //[callable_example2 int v01 = convert(str, plain_old_func).value_or(-1); //] - // Testing boost::function-based converter. + // Testing std::function-based converter. int v02 = convert(str, boost_func(plain_old_func)).value_or(-1); - // Testing crazy boost::bind-based converter. + // Testing crazy std::bind-based converter. //[callable_example3 int v03 = convert(str, - boost::bind(assign, _2, - boost::bind(lexical_cast, _1))).value_or(-1); + std::bind(assign, std::placeholders::_2, + std::bind(lexical_cast, std::placeholders::_1))).value_or(-1); //] BOOST_TEST(v01 == -12); BOOST_TEST(v02 == -12); diff --git a/test/encryption.cpp b/test/encryption.cpp index 684c6d5..7d924d1 100644 --- a/test/encryption.cpp +++ b/test/encryption.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/test/fallbacks.cpp b/test/fallbacks.cpp index b0192e9..3a1d956 100644 --- a/test/fallbacks.cpp +++ b/test/fallbacks.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -12,8 +12,7 @@ int main(int, char const* []) { return 0; } #include #include #include -#include -#include +#include namespace { namespace local { @@ -34,12 +33,12 @@ long function_long () { local::called_function_long = true; return INT_MAX; } int main(int, char const* []) { - boost::cnv::cstream cnv; - functor_foo foo; + auto cnv = boost::cnv::cstream(); + auto foo = functor_foo(); int i01 = boost::convert("uhm", cnv).value_or_eval(functor_int()); int i02 = boost::convert("uhm", cnv).value_or_eval(functor_double()); - int i03 = boost::convert("uhm", cnv).value_or_eval(boost::bind(&functor_foo::func, foo, 0)); + int i03 = boost::convert("uhm", cnv).value_or_eval(std::bind(&functor_foo::func, foo, 0)); int i04 = boost::convert("uhm", cnv).value_or_eval(function_int); int i05 = boost::convert("uhm", cnv).value_or_eval(function_long); @@ -57,7 +56,7 @@ main(int, char const* []) boost::convert("uhm", cnv, functor_int()); boost::convert("uhm", cnv, functor_double()); - boost::convert("uhm", cnv, boost::bind(&functor_foo::func, foo, 0)); + boost::convert("uhm", cnv, std::bind(&functor_foo::func, foo, 0)); boost::convert("uhm", cnv, function_int); boost::convert("uhm", cnv, function_long); diff --git a/test/has_member.cpp b/test/has_member.cpp index 088d047..94ca7dd 100644 --- a/test/has_member.cpp +++ b/test/has_member.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/test/is_converter.cpp b/test/is_converter.cpp index f528a33..92be22c 100644 --- a/test/is_converter.cpp +++ b/test/is_converter.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/test/jamfile.v2 b/test/jamfile.v2 index 9a60a3f..bbc7020 100644 --- a/test/jamfile.v2 +++ b/test/jamfile.v2 @@ -23,7 +23,7 @@ project convert_test ../include ; -exe convert_test_performance : performance.cpp /boost/timer//boost_timer ; +exe convert_test_performance : performance.cpp /boost/timer//boost_timer /boost/chrono//boost_chrono ; exe convert_test_performance_spirit : performance_spirit.cpp ; run callable.cpp : : : : convert_test_callable ; diff --git a/test/lcast_converter.cpp b/test/lcast_converter.cpp index 8cd14c4..8c8a28d 100644 --- a/test/lcast_converter.cpp +++ b/test/lcast_converter.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/test/performance.cpp b/test/performance.cpp index ac20809..2c648ef 100644 --- a/test/performance.cpp +++ b/test/performance.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -18,7 +18,7 @@ int main(int, char const* []) { return 0; } #include #include #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ namespace { namespace local template struct array { - typedef boost::array type; + typedef std::array type; }; template static typename array::type const& get(); @@ -145,9 +145,9 @@ template double raw_str_to(Converter const& cnv) { - local::strings strings = local::get_strs(); // Create strings on the stack - int const size = strings.size(); - local::timer timer; + auto strings = local::get_strs(); // Create strings on the stack + int size = strings.size(); + auto timer = local::timer(); for (int t = 0; t < local::num_cycles; ++t) for (int k = 0; k < size; ++k) @@ -160,9 +160,9 @@ template double local::str_to(Converter const& try_converter) { - local::strings strings = local::get_strs(); // Create strings on the stack - int const size = strings.size(); - local::timer timer; + auto strings = local::get_strs(); // Create strings on the stack + int size = strings.size(); + auto timer = local::timer(); for (int t = 0; t < local::num_cycles; ++t) for (int k = 0; k < size; ++k) @@ -175,11 +175,9 @@ template double local::to_str(Converter const& try_converter) { - typedef typename local::array::type collection; - - collection values = local::get(); - int const size = values.size(); - local::timer timer; + auto values = local::get(); + int size = values.size(); + auto timer = local::timer(); for (int t = 0; t < local::num_cycles; ++t) for (int k = 0; k < size; ++k) @@ -211,9 +209,9 @@ template double performance_type_to_str(Converter const& try_converter) { - boost::array input = {{ change::no, change::up, change::dn }}; - boost::array results = {{ "no", "up", "dn" }}; - local::timer timer; + std::array input = {{ change::no, change::up, change::dn }}; + std::array results = {{ "no", "up", "dn" }}; + local::timer timer; for (int k = 0; k < local::num_cycles; ++k) { diff --git a/test/performance_spirit.cpp b/test/performance_spirit.cpp index 4878b07..4aa7076 100644 --- a/test/performance_spirit.cpp +++ b/test/performance_spirit.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -19,8 +19,6 @@ int main(int, char const* []) { return 0; } #include #include "./prepare.hpp" -//#define main() old_str_to_int_test_spirit() -//#include #include #include #include diff --git a/test/prepare.hpp b/test/prepare.hpp index 15c4d01..0d244bb 100644 --- a/test/prepare.hpp +++ b/test/prepare.hpp @@ -1,12 +1,12 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. #ifndef BOOST_CONVERT_TEST_PREPARE_HPP #define BOOST_CONVERT_TEST_PREPARE_HPP -#include +#include #include #include @@ -17,7 +17,7 @@ namespace { namespace local // Even though INT_MAX(32) = 2147483647, i.e. 10 digits (not to mention long int) // we only test up to 9 digits as Spirit does not handle more than 9. - typedef boost::array strings; //C1 + typedef std::array strings; //C1 /////////////////////////////////////////////////////////////////////////// // Generate a random number string with N digits std::string @@ -28,7 +28,7 @@ namespace { namespace local if (negative) // Prepend a '-' result += '-'; - result += '1' + (std::rand()%9); // The first digit cannot be '0' + result += '1' + (std::rand() % 9); // The first digit cannot be '0' for (int i = 1; i < digits; ++i) // Generate the remaining digits result += '0' + (std::rand()%10); @@ -38,9 +38,9 @@ namespace { namespace local local::strings const& get_strs() { - static local::strings strings; - static bool filled; - static bool negative = true; + static auto strings = local::strings(); + static bool filled = false; + static bool negative = true; if (!filled) { diff --git a/test/printf_converter.cpp b/test/printf_converter.cpp index a56c95b..0a71321 100644 --- a/test/printf_converter.cpp +++ b/test/printf_converter.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/test/sfinae.cpp b/test/sfinae.cpp index 5236a4d..0df629f 100644 --- a/test/sfinae.cpp +++ b/test/sfinae.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/test/spirit_converter.cpp b/test/spirit_converter.cpp index bbbc5b9..a17c0a4 100644 --- a/test/spirit_converter.cpp +++ b/test/spirit_converter.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/test/str_to_int.cpp b/test/str_to_int.cpp index 42951c0..2031f1b 100644 --- a/test/str_to_int.cpp +++ b/test/str_to_int.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -23,42 +23,42 @@ template void int_to_str(Converter const& cnv) { - string const not_int_str = "not an int"; - string const std_str = "-11"; - char const* const c_str = "-12"; - char const array_str[] = "-15"; + string const not_int_str = "not an int"; + string const std_str = "-11"; + char const* const c_str = "-12"; + char const array_str[] = "-15"; //////////////////////////////////////////////////////////////////////////// // Testing int-to-string conversion with various string // containers as the fallback values. //////////////////////////////////////////////////////////////////////////// - string s01 = boost::convert< string>(-1, cnv).value_or(std_str); - string s02 = boost::convert< string>(-2, cnv).value_or(c_str); - string s05 = boost::convert< string>(-5, cnv).value_or(array_str); - boost::optional< string> rs01 = boost::convert< string>(-1, cnv); - boost::optional< string> rs02 = boost::convert< string>(-2, cnv); - boost::optional< string> rs05 = boost::convert< string>(-5, cnv); + string s01 = boost::convert(-1, cnv).value_or(std_str); + string s02 = boost::convert(-2, cnv).value_or(c_str); + string s05 = boost::convert(-5, cnv).value_or(array_str); + boost::optional rs01 = boost::convert(-1, cnv); + boost::optional rs02 = boost::convert(-2, cnv); + boost::optional rs05 = boost::convert(-5, cnv); - BOOST_TEST(s01 == "-1"); BOOST_TEST(rs01 && rs01.value() == "-1"); - BOOST_TEST(s02 == "-2"); BOOST_TEST(rs02 && rs02.value() == "-2"); - BOOST_TEST(s05 == "-5"); BOOST_TEST(rs05 && rs05.value() == "-5"); + BOOST_TEST(s01 == "-1"); BOOST_TEST(rs01 && rs01.value() == "-1"); + BOOST_TEST(s02 == "-2"); BOOST_TEST(rs02 && rs02.value() == "-2"); + BOOST_TEST(s05 == "-5"); BOOST_TEST(rs05 && rs05.value() == "-5"); - string s11 = boost::convert< string>(-1, cnv).value(); - boost::optional< string> rs11 = boost::convert< string>(-1, cnv); + string s11 = boost::convert(-1, cnv).value(); + boost::optional< string> rs11 = boost::convert(-1, cnv); - BOOST_TEST( s11 == "-1"); - BOOST_TEST(rs11 && rs11.value() == "-1"); + BOOST_TEST( s11 == "-1"); + BOOST_TEST(rs11 && rs11.value() == "-1"); } template void str_to_int(Converter const& cnv) { - string const not_int_str = "not an int"; - string const std_str = "-11"; - char const* const c_str = "-123"; - char const array_str[] = "3456"; + string const not_int_str = "not an int"; + string const std_str = "-11"; + char const* const c_str = "-123"; + char const array_str[] = "3456"; //////////////////////////////////////////////////////////////////////////// // Testing various kinds of string containers. @@ -132,11 +132,11 @@ str_to_int(Converter const& cnv) int main(int, char const* []) { - boost::cnv::lexical_cast lxcast_cnv; - boost::cnv::cstream stream_cnv; - boost::cnv::strtol strtol_cnv; - boost::cnv::printf printf_cnv; - boost::cnv::spirit spirit_cnv; + auto lxcast_cnv = boost::cnv::lexical_cast(); + auto stream_cnv = boost::cnv::cstream(); + auto strtol_cnv = boost::cnv::strtol(); + auto printf_cnv = boost::cnv::printf(); + auto spirit_cnv = boost::cnv::spirit(); str_to_int(lxcast_cnv); str_to_int(stream_cnv); diff --git a/test/stream_converter.cpp b/test/stream_converter.cpp index fcab03d..3a85a0f 100644 --- a/test/stream_converter.cpp +++ b/test/stream_converter.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -197,8 +197,8 @@ static void test_manipulators() { - boost::cnv::cstream ccnv; - boost::cnv::wstream wcnv; + auto ccnv = boost::cnv::cstream(); + auto wcnv = boost::cnv::wstream(); int const hex_v01 = boost::convert("FF", ccnv(std::hex)).value_or(0); int const hex_v02 = boost::convert(L"F", wcnv(std::hex)).value_or(0); diff --git a/test/strtol_converter.cpp b/test/strtol_converter.cpp index 69e33e3..92f4fbf 100644 --- a/test/strtol_converter.cpp +++ b/test/strtol_converter.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -289,7 +289,7 @@ get_random() static void -compare(std::pair pair) +compare(std::pair pair) { boost::cnv::strtol cnv1; boost::cnv::printf cnv2; diff --git a/test/test.hpp b/test/test.hpp index e2fbbc6..cf1483e 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -7,11 +7,9 @@ #include #include -#include #include #include #include // For strlen, strcmp, memcpy -#include // Is needed for 'memset' #include #include @@ -112,10 +110,10 @@ namespace boost //[my_string_declaration struct my_string { - typedef my_string this_type; - typedef char value_type; - typedef value_type* iterator; - typedef value_type const* const_iterator; + using this_type = my_string; + using value_type = char; + using iterator = value_type*; + using const_iterator = value_type const*; my_string (); my_string (const_iterator, const_iterator =0); diff --git a/test/user_type.cpp b/test/user_type.cpp index bd2bb54..fad0ff8 100644 --- a/test/user_type.cpp +++ b/test/user_type.cpp @@ -1,5 +1,5 @@ // Boost.Convert test and usage example -// Copyright (c) 2009-2016 Vladimir Batov. +// Copyright (c) 2009-2020 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -12,7 +12,7 @@ int main(int, char const* []) { return 0; } #include #include #include -#include +#include #include using std::string; @@ -54,18 +54,19 @@ void test_algorithms() { //[algorithm_example6 - boost::array chgs1 = {{ change::no, change::up, change::dn }}; - boost::array chgs2 = {{ change::no, change::up, change::dn }}; - std::vector strs1; - std::vector strs2; - std::vector strs3; - boost::cnv::cstream cnv; + std::array chgs1 = {{ change::no, change::up, change::dn }}; + std::array chgs2 = {{ change::no, change::up, change::dn }}; + + auto strs1 = std::vector(); + auto strs2 = std::vector(); + auto strs3 = std::vector(); + auto cnv = boost::cnv::cstream(); std::transform(chgs1.begin(), chgs1.end(), std::back_inserter(strs1), - boost::cnv::apply(boost::cref(cnv))); // Deduced TypeIn is 'change' + boost::cnv::apply(std::cref(cnv))); // Deduced TypeIn is 'change' std::transform(chgs2.begin(), chgs2.end(), std::back_inserter(strs2), - boost::cnv::apply(boost::cref(cnv))); // Deduced TypeIn is 'change::value_type' + boost::cnv::apply(std::cref(cnv))); // Deduced TypeIn is 'change::value_type' BOOST_TEST(strs1.size() == 3); BOOST_TEST(strs1[0] == "no"); @@ -80,7 +81,7 @@ test_algorithms() //[algorithm_example7 std::transform(chgs2.begin(), chgs2.end(), std::back_inserter(strs3), - boost::cnv::apply(boost::cref(cnv))); + boost::cnv::apply(std::cref(cnv))); BOOST_TEST(strs3.size() == 3); BOOST_TEST(strs3[0] == "no");