From 68ac0aa5780b35cf35141e4dde4959fe7fe1459d Mon Sep 17 00:00:00 2001 From: Vladimir Batov Date: Tue, 20 May 2014 23:15:17 +1000 Subject: [PATCH] removed struct convert --- include/boost/convert/allocate_storage.hpp | 13 -- include/boost/convert/api.hpp | 35 +--- .../boost/convert/detail/algorithm_helper.hpp | 5 +- include/boost/convert/forward.hpp | 26 +++ include/boost/convert/result.hpp | 10 +- test/algorithms.cpp | 8 +- test/callable.cpp | 6 +- test/encryption.cpp | 4 +- test/performance.cpp | 8 +- test/test_convert.cpp | 160 +++++++++--------- 10 files changed, 134 insertions(+), 141 deletions(-) delete mode 100644 include/boost/convert/allocate_storage.hpp create mode 100644 include/boost/convert/forward.hpp diff --git a/include/boost/convert/allocate_storage.hpp b/include/boost/convert/allocate_storage.hpp deleted file mode 100644 index a29a921..0000000 --- a/include/boost/convert/allocate_storage.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2009-2014 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_ALLOCATE_STORAGE_HPP -#define BOOST_CONVERT_ALLOCATE_STORAGE_HPP - -namespace boost -{ - template T allocate_storage() { return T(); } -} - -#endif // BOOST_CONVERT_ALLOCATE_STORAGE_HPP diff --git a/include/boost/convert/api.hpp b/include/boost/convert/api.hpp index f81ab26..b2ded33 100644 --- a/include/boost/convert/api.hpp +++ b/include/boost/convert/api.hpp @@ -15,17 +15,12 @@ #ifndef BOOST_CONVERT_API_HPP #define BOOST_CONVERT_API_HPP +#include #include #include #include namespace boost -{ - template struct convert; -} - -template -struct boost::convert { // C1. TypeOut needs to be normalized as, say, "char const*" might be provided when // std::string will be used instead (as we have to have storage for the conversion result). @@ -36,35 +31,23 @@ struct boost::convert // a) ensures the consistent requirement with regard to "out_type" // (rather than every converter imposing their own); // b) relieves the converter of that responsibility and makes writing converters easier. - - typedef boost::convert this_type; - typedef typename convert_detail::corrected::type out_type; //C1 - typedef typename boost::conversion::result result_type; //C1 - template - static - result_type - from(TypeIn const& value_in, Converter const& converter) + template + boost::conversion::result + convert(TypeIn const& value_in, Converter const& converter) { - result_type result (boost::allocate_storage()); //C1,C3 + typedef typename convert_detail::corrected::type out_type; //C1 + typedef boost::conversion::result result_type; //C1 + + result_type result (boost::allocate_storage()); //C1,C3 bool success = converter(value_in, result.value_); //C1,C2,C3 return success ? result : result(false); } -}; - -namespace boost -{ - template - boost::conversion::result - cnv(TypeIn const& value_in, Converter const& converter) - { - return boost::convert::from(value_in, converter); - } template typename boost::conversion::algorithm_helper - cnv(Converter const& cnv) + convert(Converter const& cnv) { return boost::conversion::algorithm_helper(cnv); } diff --git a/include/boost/convert/detail/algorithm_helper.hpp b/include/boost/convert/detail/algorithm_helper.hpp index 9786cc4..cfd9825 100644 --- a/include/boost/convert/detail/algorithm_helper.hpp +++ b/include/boost/convert/detail/algorithm_helper.hpp @@ -7,16 +7,13 @@ #ifndef BOOST_CONVERT_DETAIL_ALGORITHM_HELPER_HPP #define BOOST_CONVERT_DETAIL_ALGORITHM_HELPER_HPP -#include +#include #include #include #include namespace boost { namespace conversion { - template struct algorithm_helper; - template struct algorithm_helper_with_fallback; - template struct algorithm_helper { diff --git a/include/boost/convert/forward.hpp b/include/boost/convert/forward.hpp new file mode 100644 index 0000000..9d9bc92 --- /dev/null +++ b/include/boost/convert/forward.hpp @@ -0,0 +1,26 @@ +// Boost.Convert library +// Copyright (c) 2009-2014 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_FORWARD_HPP +#define BOOST_CONVERT_FORWARD_HPP + +namespace boost +{ + namespace conversion + { + template struct algorithm_helper; + template struct algorithm_helper_with_fallback; + template struct result; + } + + template + boost::conversion::result + convert(TypeIn const&, Converter const&); + + template T allocate_storage() { return T(); } +} + +#endif // BOOST_CONVERT_FORWARD_HPP diff --git a/include/boost/convert/result.hpp b/include/boost/convert/result.hpp index 6956f8e..6bf4eaa 100644 --- a/include/boost/convert/result.hpp +++ b/include/boost/convert/result.hpp @@ -7,15 +7,12 @@ #ifndef BOOST_CONVERT_RESULT_HPP #define BOOST_CONVERT_RESULT_HPP +#include #include #include #include #include -namespace boost -{ - template struct convert; -} namespace boost { namespace conversion { // Used temporarily. To be replaced with std::tr2::optional or improved boost::optional. @@ -48,7 +45,10 @@ namespace boost { namespace conversion private: - friend struct boost::convert; + template + friend + boost::conversion::result + boost::convert(TypeIn const& value_in, Converter const& converter); this_type& operator()(bool good) { return (good_ = good, *this); } diff --git a/test/algorithms.cpp b/test/algorithms.cpp index 909b16f..28ce599 100644 --- a/test/algorithms.cpp +++ b/test/algorithms.cpp @@ -38,7 +38,7 @@ test::algorithms() strings.begin(), strings.end(), std::back_inserter(integers), - boost::cnv(ccnv(std::hex))); + boost::convert(ccnv(std::hex))); BOOST_TEST(!"Failed to throw"); } @@ -62,7 +62,7 @@ test::algorithms() strings.begin(), strings.end(), std::back_inserter(integers), - boost::cnv(ccnv(arg::base = cnv::base::hex)).value_or(-1)); + boost::convert(ccnv(arg::base = cnv::base::hex)).value_or(-1)); BOOST_TEST(integers.size() == 5); BOOST_TEST(integers[0] == 15); @@ -79,7 +79,7 @@ test::algorithms() strings.begin(), strings.end(), std::back_inserter(opt_ints), - boost::cnv(ccnv(arg::base = cnv::base::hex))); + boost::convert(ccnv(arg::base = cnv::base::hex))); BOOST_TEST(opt_ints.size() == 5); BOOST_TEST( opt_ints[0]); @@ -102,7 +102,7 @@ test::algorithms() integers.begin(), integers.end(), std::back_inserter(new_strings), - boost::cnv(ccnv(std::dec))); + boost::convert(ccnv(std::dec))); BOOST_TEST(new_strings.size() == 5); BOOST_TEST(new_strings[0] == "15"); diff --git a/test/callable.cpp b/test/callable.cpp index f348f30..1aa94d3 100644 --- a/test/callable.cpp +++ b/test/callable.cpp @@ -37,11 +37,11 @@ test::callables() char const* const str = "-12"; // Testing old-function-based converter. - int v01 = boost::cnv(str, plain_old_func).value_or(-1); + int v01 = boost::convert(str, plain_old_func).value_or(-1); // Testing boost::function-based converter. - int v02 = boost::cnv(str, boost_func(plain_old_func)).value_or(-1); + int v02 = boost::convert(str, boost_func(plain_old_func)).value_or(-1); // Testing crazy boost::bind-based converter. - int v03 = boost::cnv(str, boost::bind(assign, _2, boost::bind(boost::lexical_cast, _1))).value_or(-1); + int v03 = boost::convert(str, boost::bind(assign, _2, boost::bind(boost::lexical_cast, _1))).value_or(-1); BOOST_TEST(v01 == -12); BOOST_TEST(v02 == -12); diff --git a/test/encryption.cpp b/test/encryption.cpp index 9dc1cb9..8924d24 100644 --- a/test/encryption.cpp +++ b/test/encryption.cpp @@ -24,8 +24,8 @@ test::encryption() // Testing custom converter. //////////////////////////////////////////////////////////////////////////// - string encrypted = boost::cnv("ABC", my_cypher).value(); - string decrypted = boost::cnv(encrypted, my_cypher).value(); + string encrypted = boost::convert("ABC", my_cypher).value(); + string decrypted = boost::convert(encrypted, my_cypher).value(); BOOST_TEST(encrypted == "123"); BOOST_TEST(decrypted == "ABC"); diff --git a/test/performance.cpp b/test/performance.cpp index 800f842..a62268b 100644 --- a/test/performance.cpp +++ b/test/performance.cpp @@ -15,7 +15,7 @@ performance_string_to_type(Converter const& try_converter) for (int k = 0; k < test::num_cycles; ++k) { - change chg = boost::cnv(input[k % 3], try_converter).value(); + change chg = boost::convert(input[k % 3], try_converter).value(); int res = chg.value(); BOOST_TEST(res == k % 3); @@ -37,7 +37,7 @@ performance_string_to_int(Converter const& try_converter) double p1 = clock(); for (int k = 0; k < test::num_cycles; ++k) - sum += boost::cnv((str[4 - k % 5] = 49 + k % 9, str), try_converter).value(); + sum += boost::convert((str[4 - k % 5] = 49 + k % 9, str), try_converter).value(); double p2 = clock(); int use_sum = (sum % 2) ? 0 : (sum % 2); BOOST_TEST(use_sum == 0); @@ -53,12 +53,12 @@ performance_int_to_string(Converter const& try_converter) double p1 = clock(); for (int k = 0; k < test::num_cycles; ++k) - res.push_back(boost::cnv(k, try_converter).value()); + res.push_back(boost::convert(k, try_converter).value()); double p2 = clock(); for (int k = 0; k < test::num_cycles; ++k) - BOOST_TEST(k == boost::cnv(res[k], try_converter).value()); + BOOST_TEST(k == boost::convert(res[k], try_converter).value()); return (p2 - p1) / CLOCKS_PER_SEC; } diff --git a/test/test_convert.cpp b/test/test_convert.cpp index e57b590..7572c4e 100644 --- a/test/test_convert.cpp +++ b/test/test_convert.cpp @@ -19,20 +19,20 @@ template void test::type_to_string(Converter const& cnv) { - BOOST_TEST("255" == boost::cnv(255, cnv(arg::base = cnv::base::dec)).value_or("bad")); - BOOST_TEST( "ff" == boost::cnv(255, cnv(arg::base = cnv::base::hex)).value_or("bad")); - BOOST_TEST("377" == boost::cnv(255, cnv(arg::base = cnv::base::oct)).value_or("bad")); + BOOST_TEST("255" == boost::convert(255, cnv(arg::base = cnv::base::dec)).value_or("bad")); + BOOST_TEST( "ff" == boost::convert(255, cnv(arg::base = cnv::base::hex)).value_or("bad")); + BOOST_TEST("377" == boost::convert(255, cnv(arg::base = cnv::base::oct)).value_or("bad")); } template void test::string_to_type(Converter const& cnv) { - BOOST_TEST( 255 == boost::cnv("255", cnv(arg::base = cnv::base::dec)).value_or(999)); - BOOST_TEST( 999 == boost::cnv( "FF", cnv(arg::base = cnv::base::dec)).value_or(999)); - BOOST_TEST( 255 == boost::cnv( "FF", cnv(arg::base = cnv::base::hex)).value_or(999)); - BOOST_TEST( 173 == boost::cnv("255", cnv(arg::base = cnv::base::oct)).value_or(999)); - BOOST_TEST( 999 != boost::cnv("1.23", cnv).value_or(999)); + BOOST_TEST( 255 == boost::convert("255", cnv(arg::base = cnv::base::dec)).value_or(999)); + BOOST_TEST( 999 == boost::convert( "FF", cnv(arg::base = cnv::base::dec)).value_or(999)); + BOOST_TEST( 255 == boost::convert( "FF", cnv(arg::base = cnv::base::hex)).value_or(999)); + BOOST_TEST( 173 == boost::convert("255", cnv(arg::base = cnv::base::oct)).value_or(999)); + BOOST_TEST( 999 != boost::convert("1.23", cnv).value_or(999)); } int @@ -65,9 +65,9 @@ main(int argc, char const* argv[]) // Testing lexical_cast-based converter. //////////////////////////////////////////////////////////////////////////// - int lc00 = boost::cnv(not_int_str, lcnv).value_or(-1); - int lc01 = boost::cnv(std_str, lcnv).value_or(-1); - int lc02 = boost::cnv(c_str, lcnv).value_or(-1); + int lc00 = boost::convert(not_int_str, lcnv).value_or(-1); + int lc01 = boost::convert(std_str, lcnv).value_or(-1); + int lc02 = boost::convert(c_str, lcnv).value_or(-1); BOOST_TEST(lc00 == -1); // Failed conversion. No throw BOOST_TEST(lc01 == -11); @@ -80,12 +80,12 @@ main(int argc, char const* argv[]) // On failure returns the provided fallback value and DOES NOT THROW. //////////////////////////////////////////////////////////////////////////// - int a000 = boost::cnv(not_int_str, ccnv).value_or(-1); - int a001 = boost::cnv(std_str, ccnv).value_or(-1); - int a002 = boost::cnv(c_str, ccnv).value_or(-1); - int a003 = boost::cnv(wstd_str, wcnv).value_or(-1); - int a004 = boost::cnv(wc_str, wcnv).value_or(-1); - int a005 = boost::cnv(array_str, ccnv).value_or(-1); + int a000 = boost::convert(not_int_str, ccnv).value_or(-1); + int a001 = boost::convert(std_str, ccnv).value_or(-1); + int a002 = boost::convert(c_str, ccnv).value_or(-1); + int a003 = boost::convert(wstd_str, wcnv).value_or(-1); + int a004 = boost::convert(wc_str, wcnv).value_or(-1); + int a005 = boost::convert(array_str, ccnv).value_or(-1); BOOST_TEST(a000 == -1); // Failed conversion BOOST_TEST(a001 == -11); @@ -101,12 +101,12 @@ main(int argc, char const* argv[]) // on failure it returns the provided fallback value and DOES NOT THROW. //////////////////////////////////////////////////////////////////////////// - boost::conversion::result r000 = boost::cnv(not_int_str, ccnv); - boost::conversion::result r001 = boost::cnv(std_str, ccnv); - boost::conversion::result r002 = boost::cnv(c_str, ccnv); - boost::conversion::result r003 = boost::cnv(wstd_str, wcnv); - boost::conversion::result r004 = boost::cnv(wc_str, wcnv); - boost::conversion::result r005 = boost::cnv(array_str, ccnv); + boost::conversion::result r000 = boost::convert(not_int_str, ccnv); + boost::conversion::result r001 = boost::convert(std_str, ccnv); + boost::conversion::result r002 = boost::convert(c_str, ccnv); + boost::conversion::result r003 = boost::convert(wstd_str, wcnv); + boost::conversion::result r004 = boost::convert(wc_str, wcnv); + boost::conversion::result r005 = boost::convert(array_str, ccnv); BOOST_TEST(!r000); // Failed conversion BOOST_TEST( r001 && r001.value() == -11); @@ -123,18 +123,18 @@ main(int argc, char const* argv[]) try { - boost::cnv(not_int_str, ccnv).value(); + boost::convert(not_int_str, ccnv).value(); BOOST_TEST(!"failed to throw"); } catch (std::exception&) { // Expected behavior: received 'boost::convert failed' exception. All well. } - int a021 = boost::cnv(std_str, ccnv).value(); - int a022 = boost::cnv(c_str, ccnv).value(); - int a023 = boost::cnv(wstd_str, wcnv).value(); - int a024 = boost::cnv(wc_str, wcnv).value(); - int a025 = boost::cnv(array_str, ccnv).value(); + int a021 = boost::convert(std_str, ccnv).value(); + int a022 = boost::convert(c_str, ccnv).value(); + int a023 = boost::convert(wstd_str, wcnv).value(); + int a024 = boost::convert(wc_str, wcnv).value(); + int a025 = boost::convert(array_str, ccnv).value(); BOOST_TEST(a021 == -11); BOOST_TEST(a022 == -12); @@ -149,12 +149,12 @@ main(int argc, char const* argv[]) // as there is nothing to return. //////////////////////////////////////////////////////////////////////////// - boost::conversion::result r010 = boost::cnv(not_int_str, ccnv); - boost::conversion::result r011 = boost::cnv(std_str, ccnv); - boost::conversion::result r012 = boost::cnv(c_str, ccnv); - boost::conversion::result r013 = boost::cnv(wstd_str, wcnv); - boost::conversion::result r014 = boost::cnv(wc_str, wcnv); - boost::conversion::result r015 = boost::cnv(array_str, ccnv); + boost::conversion::result r010 = boost::convert(not_int_str, ccnv); + boost::conversion::result r011 = boost::convert(std_str, ccnv); + boost::conversion::result r012 = boost::convert(c_str, ccnv); + boost::conversion::result r013 = boost::convert(wstd_str, wcnv); + boost::conversion::result r014 = boost::convert(wc_str, wcnv); + boost::conversion::result r015 = boost::convert(array_str, ccnv); BOOST_TEST(!r010); // Failed conversion BOOST_TEST( r011 && r011.value() == -11); @@ -177,16 +177,16 @@ main(int argc, char const* argv[]) // containers as the fallback values. //////////////////////////////////////////////////////////////////////////// - string s001 = boost::cnv< string>(-5, ccnv).value_or(std_str); - string s002 = boost::cnv< string>(-5, ccnv).value_or(c_str); - wstring s003 = boost::cnv(-5, wcnv).value_or(wstd_str); - wstring s004 = boost::cnv(-5, wcnv).value_or(wc_str); - string s005 = boost::cnv< string>(-5, ccnv).value_or(array_str); - boost::conversion::result< string> rs001 = boost::cnv< string>(-5, ccnv); - boost::conversion::result< string> rs002 = boost::cnv< string>(-5, ccnv); - boost::conversion::result rs003 = boost::cnv(-5, wcnv); - boost::conversion::result rs004 = boost::cnv(-5, wcnv); - boost::conversion::result< string> rs005 = boost::cnv< string>(-5, ccnv); + string s001 = boost::convert< string>(-5, ccnv).value_or(std_str); + string s002 = boost::convert< string>(-5, ccnv).value_or(c_str); + wstring s003 = boost::convert(-5, wcnv).value_or(wstd_str); + wstring s004 = boost::convert(-5, wcnv).value_or(wc_str); + string s005 = boost::convert< string>(-5, ccnv).value_or(array_str); + boost::conversion::result< string> rs001 = boost::convert< string>(-5, ccnv); + boost::conversion::result< string> rs002 = boost::convert< string>(-5, ccnv); + boost::conversion::result rs003 = boost::convert(-5, wcnv); + boost::conversion::result rs004 = boost::convert(-5, wcnv); + boost::conversion::result< string> rs005 = boost::convert< string>(-5, ccnv); BOOST_TEST(s001 == "-5"); BOOST_TEST(rs001 && rs001.value() == "-5"); BOOST_TEST(s002 == "-5"); BOOST_TEST(rs002 && rs002.value() == "-5"); @@ -198,10 +198,10 @@ main(int argc, char const* argv[]) // Testing int-to-string conversion with no fallback value. //////////////////////////////////////////////////////////////////////////// - string s010 = boost::cnv< string>(-5, ccnv).value(); - wstring s011 = boost::cnv(-5, wcnv).value(); - boost::conversion::result< string> rs010 = boost::cnv< string>(-5, ccnv); - boost::conversion::result rs011 = boost::cnv(-5, wcnv); + string s010 = boost::convert< string>(-5, ccnv).value(); + wstring s011 = boost::convert(-5, wcnv).value(); + boost::conversion::result< string> rs010 = boost::convert< string>(-5, ccnv); + boost::conversion::result rs011 = boost::convert(-5, wcnv); BOOST_TEST( s010 == "-5"); BOOST_TEST( s011 == L"-5"); @@ -214,16 +214,16 @@ main(int argc, char const* argv[]) direction const up_dir1 = direction::up; direction const dn_dir1 = direction::dn; - string up_dir0_str = boost::cnv(direction::up, ccnv).value(); - string dn_dir0_str = boost::cnv(direction::dn, ccnv).value(); - string up_dir1_str = boost::cnv(up_dir1, ccnv).value(); - string dn_dir1_str = boost::cnv(dn_dir1, ccnv).value(); - direction up_dir2 = boost::cnv(up_dir1_str, ccnv).value(); - direction dn_dir2 = boost::cnv(dn_dir1_str, ccnv).value(); - direction up_dir3 = boost::cnv(up_dir1_str, ccnv).value(); - direction dn_dir3 = boost::cnv(dn_dir1_str, ccnv).value(); - direction dn_dir4 = boost::cnv("junk", ccnv).value_or(direction::dn); - boost::conversion::result up_dir4 = boost::cnv("junk", ccnv); + string up_dir0_str = boost::convert(direction::up, ccnv).value(); + string dn_dir0_str = boost::convert(direction::dn, ccnv).value(); + string up_dir1_str = boost::convert(up_dir1, ccnv).value(); + string dn_dir1_str = boost::convert(dn_dir1, ccnv).value(); + direction up_dir2 = boost::convert(up_dir1_str, ccnv).value(); + direction dn_dir2 = boost::convert(dn_dir1_str, ccnv).value(); + direction up_dir3 = boost::convert(up_dir1_str, ccnv).value(); + direction dn_dir3 = boost::convert(dn_dir1_str, ccnv).value(); + direction dn_dir4 = boost::convert("junk", ccnv).value_or(direction::dn); + boost::conversion::result up_dir4 = boost::convert("junk", ccnv); BOOST_TEST(up_dir0_str == "up"); BOOST_TEST(dn_dir0_str == "dn"); @@ -249,10 +249,10 @@ main(int argc, char const* argv[]) { } - int hex_v01 = boost::cnv("FF", ccnv(std::hex)).value_or(0); - int hex_v02 = boost::cnv(L"F", wcnv(std::hex)).value_or(0); - int hex_v03 = boost::cnv("FF", ccnv(std::dec)).value_or(-5); - int hex_v04 = boost::cnv(L"F", wcnv(std::dec)).value_or(-5); + int hex_v01 = boost::convert("FF", ccnv(std::hex)).value_or(0); + int hex_v02 = boost::convert(L"F", wcnv(std::hex)).value_or(0); + int hex_v03 = boost::convert("FF", ccnv(std::dec)).value_or(-5); + int hex_v04 = boost::convert(L"F", wcnv(std::dec)).value_or(-5); BOOST_TEST(hex_v01 == 255); // "FF" BOOST_TEST(hex_v02 == 15); // L"F" @@ -261,8 +261,8 @@ main(int argc, char const* argv[]) ccnv(std::showbase)(std::uppercase)(std::hex); - BOOST_TEST(boost::cnv(255, ccnv).value() == "0XFF"); - BOOST_TEST(boost::cnv( 15, ccnv).value() == "0XF"); + BOOST_TEST(boost::convert(255, ccnv).value() == "0XFF"); + BOOST_TEST(boost::convert( 15, ccnv).value() == "0XF"); char const* double_s01 = test::is_msc ? "1.2345E-002" : test::is_gcc ? "1.2345E-02" @@ -272,8 +272,8 @@ main(int argc, char const* argv[]) (arg::uppercase = true) (arg::notation = cnv::notation::scientific); - double double_v01 = boost::cnv(double_s01, ccnv).value(); - string double_s02 = boost::cnv(double_v01, ccnv).value(); + double double_v01 = boost::convert(double_s01, ccnv).value(); + string double_s02 = boost::convert(double_v01, ccnv).value(); BOOST_TEST(double_s01 == double_s02); @@ -300,8 +300,8 @@ main(int argc, char const* argv[]) // ccnv(std::setprecision(3))(std::nouppercase); ccnv(arg::precision = 3)(arg::uppercase = false); - string double_rus = boost::cnv(double_v01, ccnv(rus_locale)).value(); - string double_eng = boost::cnv(double_v01, ccnv(eng_locale)).value(); + string double_rus = boost::convert(double_v01, ccnv(rus_locale)).value(); + string double_eng = boost::convert(double_v01, ccnv(eng_locale)).value(); printf("rus locale=%s, presentation=%s.\n", rus_locale.name().c_str(), double_rus.c_str()); printf("eng locale=%s, presentation=%s.\n", eng_locale.name().c_str(), double_eng.c_str()); @@ -312,13 +312,13 @@ main(int argc, char const* argv[]) // Testing string-to-bool and bool-to-string conversions //////////////////////////////////////////////////////////////////////////// -// boost::conversion::resultt bool_res1 = boost::cnv("1", false, ccnv); -// boost::conversion::resultt bool_res2 = boost::cnv("true", false, ccnv); -// boost::conversion::resultt bool_res3 = boost::cnv("yes", false, ccnv); -// boost::conversion::resultt bool_res4 = boost::cnv(L"1", false, wcnv); -// boost::conversion::resultt bool_res5 = boost::cnv(L"true", false, wcnv); -// boost::conversion::resultt bool_res6 = boost::cnv(L"yes", false, wcnv); -// boost::conversion::resultt bool_res7 = boost::cnv("junk", true, ccnv); +// boost::conversion::resultt bool_res1 = boost::convert("1", false, ccnv); +// boost::conversion::resultt bool_res2 = boost::convert("true", false, ccnv); +// boost::conversion::resultt bool_res3 = boost::convert("yes", false, ccnv); +// boost::conversion::resultt bool_res4 = boost::convert(L"1", false, wcnv); +// boost::conversion::resultt bool_res5 = boost::convert(L"true", false, wcnv); +// boost::conversion::resultt bool_res6 = boost::convert(L"yes", false, wcnv); +// boost::conversion::resultt bool_res7 = boost::convert("junk", true, ccnv); // // BOOST_TEST( bool_res1 && bool_res1.value() == true); // BOOST_TEST( bool_res2 && bool_res2.value() == true); @@ -328,10 +328,10 @@ main(int argc, char const* argv[]) // BOOST_TEST( bool_res6 && bool_res6.value() == true); // BOOST_TEST(!bool_res7 && bool_res7.value() == true); // -// string bool_str1 = boost::cnv(true, ccnv).value_or("failed"); -// string bool_str2 = boost::cnv(false, ccnv).value_or("failed"); -// string bool_str3 = boost::cnv(1, ccnv).value_or("failed"); -// string bool_str4 = boost::cnv(0, ccnv).value_or("failed"); +// string bool_str1 = boost::convert(true, ccnv).value_or("failed"); +// string bool_str2 = boost::convert(false, ccnv).value_or("failed"); +// string bool_str3 = boost::convert(1, ccnv).value_or("failed"); +// string bool_str4 = boost::convert(0, ccnv).value_or("failed"); // // BOOST_TEST(bool_str1 == "1"); // BOOST_TEST(bool_str2 == "0");