diff --git a/include/boost/convert/api.hpp b/include/boost/convert/api.hpp index bbd137c..465b252 100644 --- a/include/boost/convert/api.hpp +++ b/include/boost/convert/api.hpp @@ -24,6 +24,8 @@ namespace boost { template struct convert; + + template T allocate_storage() { return T(); } } template @@ -40,31 +42,29 @@ struct boost::convert // b) relieves the converter of that responsibility and makes writing converters easier. struct result; - template struct algorithm_helper; + template struct algorithm_helper; typedef boost::convert this_type; typedef typename convert_detail::corrected::type out_type; //C1 typedef typename boost::convert::result result_type; //C1 - static out_type create_storage() { return out_type(); } - template static result_type from(TypeIn const& value_in, Converter const& converter) { - result_type result (this_type::create_storage()); //C1,C3 + result_type result (boost::allocate_storage()); //C1,C3 bool success = converter(value_in, result.value_); //C1,C2,C3 return success ? result : result(false); } - template + template static - algorithm_helper + algorithm_helper from(Converter const& cnv) { - return algorithm_helper(cnv); + return algorithm_helper(cnv); } }; @@ -107,7 +107,7 @@ struct boost::convert::result }; template -template +template struct boost::convert::algorithm_helper { struct with_fallback; @@ -120,9 +120,9 @@ struct boost::convert::algorithm_helper with_fallback value_or(FallbackType const&); - TypeOut operator()(TypeIn const& value_in) + template TypeOut operator()(TypeIn const& value_in) { - out_type result = boost::convert::create_storage(); + out_type result = boost::allocate_storage(); bool good = (*converter_)(value_in, result); if (!good) @@ -137,16 +137,16 @@ struct boost::convert::algorithm_helper }; template -template -struct boost::convert::algorithm_helper::with_fallback +template +struct boost::convert::algorithm_helper::with_fallback : - public boost::convert::template algorithm_helper + public boost::convert::template algorithm_helper { typedef with_fallback this_type; #if defined(_MSC_VER) - typedef typename boost::convert::algorithm_helper base_type; + typedef typename boost::convert::algorithm_helper base_type; #else - typedef boost::convert::algorithm_helper base_type; + typedef boost::convert::algorithm_helper base_type; #endif with_fallback(base_type const& ah, TypeOut const& fallback) : @@ -154,9 +154,9 @@ struct boost::convert::algorithm_helper::with_fallba fallback_ (fallback) {} - TypeOut operator()(TypeIn const& value_in) + template TypeOut operator()(TypeIn const& value_in) { - out_type result = boost::convert::create_storage(); + out_type result = boost::allocate_storage(); bool good = (*converter_)(value_in, result); return good ? result : fallback_; @@ -166,10 +166,10 @@ struct boost::convert::algorithm_helper::with_fallba }; template -template +template template -typename boost::convert::template algorithm_helper::with_fallback -boost::convert::algorithm_helper::value_or(FallbackType const& fallback) +typename boost::convert::template algorithm_helper::with_fallback +boost::convert::algorithm_helper::value_or(FallbackType const& fallback) { return with_fallback(*this, fallback); } @@ -182,11 +182,11 @@ namespace boost { return boost::convert::from(value_in, converter); } - template - typename boost::convert::template algorithm_helper + template + typename boost::convert::template algorithm_helper cnv(Converter const& cnv) { - return boost::convert::template from(cnv); + return boost::convert::template from(cnv); } } diff --git a/test/algorithms.cpp b/test/algorithms.cpp index b883aff..84b8191 100644 --- a/test/algorithms.cpp +++ b/test/algorithms.cpp @@ -38,8 +38,7 @@ test::algorithms() strings.begin(), strings.end(), std::back_inserter(integers), -// boost::convert::from(ccnv(std::hex))); - boost::cnv(ccnv(std::hex))); + boost::cnv(ccnv(std::hex))); BOOST_TEST(!"Failed to throw"); } @@ -63,8 +62,7 @@ test::algorithms() strings.begin(), strings.end(), std::back_inserter(integers), -// boost::convert::from(ccnv(arg::base = cnv::base::hex)).value_or(-1)); - boost::cnv(ccnv(arg::base = cnv::base::hex)).value_or(-1)); + boost::cnv(ccnv(arg::base = cnv::base::hex)).value_or(-1)); BOOST_TEST(integers.size() == 5); BOOST_TEST(integers[0] == 15); @@ -81,7 +79,7 @@ test::algorithms() strings.begin(), strings.end(), std::back_inserter(opt_ints), - boost::convert::from(ccnv(arg::base = cnv::base::hex))); + boost::cnv(ccnv(arg::base = cnv::base::hex))); BOOST_TEST(opt_ints.size() == 5); BOOST_TEST( opt_ints[0]); @@ -104,7 +102,7 @@ test::algorithms() integers.begin(), integers.end(), std::back_inserter(new_strings), - boost::convert::from(ccnv(std::dec))); + boost::cnv(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 84da01f..f348f30 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 = convert::from(str, plain_old_func).value_or(-1); + int v01 = boost::cnv(str, plain_old_func).value_or(-1); // Testing boost::function-based converter. - int v02 = convert::from(str, boost_func(plain_old_func)).value_or(-1); + int v02 = boost::cnv(str, boost_func(plain_old_func)).value_or(-1); // Testing crazy boost::bind-based converter. - int v03 = convert::from(str, boost::bind(assign, _2, boost::bind(boost::lexical_cast, _1))).value_or(-1); + int v03 = boost::cnv(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 ff57582..9dc1cb9 100644 --- a/test/encryption.cpp +++ b/test/encryption.cpp @@ -2,7 +2,6 @@ using std::string; using std::wstring; -using boost::convert; static bool @@ -25,8 +24,8 @@ test::encryption() // Testing custom converter. //////////////////////////////////////////////////////////////////////////// - string encrypted = convert::from("ABC", my_cypher).value(); - string decrypted = convert::from(encrypted, my_cypher).value(); + string encrypted = boost::cnv("ABC", my_cypher).value(); + string decrypted = boost::cnv(encrypted, my_cypher).value(); BOOST_TEST(encrypted == "123"); BOOST_TEST(decrypted == "ABC"); diff --git a/test/performance.cpp b/test/performance.cpp index 8a3d34d..800f842 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::convert::from(input[k % 3], try_converter).value(); + change chg = boost::cnv(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::convert::from((str[4 - k % 5] = 49 + k % 9, str), try_converter).value(); + sum += boost::cnv((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::convert::from(k, try_converter).value()); + res.push_back(boost::cnv(k, try_converter).value()); double p2 = clock(); for (int k = 0; k < test::num_cycles; ++k) - BOOST_TEST(k == boost::convert::from(res[k], try_converter).value()); + BOOST_TEST(k == boost::cnv(res[k], try_converter).value()); return (p2 - p1) / CLOCKS_PER_SEC; } diff --git a/test/test.hpp b/test/test.hpp index b760433..90e54cd 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -23,20 +23,20 @@ struct change change(value_type v =no) : value_(v) {} - friend std::istream& operator>>(std::istream& stream, this_type& dir) + friend std::istream& operator>>(std::istream& stream, this_type& chg) { std::string str; stream >> str; - /**/ if (str == "up") dir.value_ = up; - else if (str == "dn") dir.value_ = dn; - else if (str == "no") dir.value_ = no; + /**/ if (str == "up") chg.value_ = up; + else if (str == "dn") chg.value_ = dn; + else if (str == "no") chg.value_ = no; else stream.setstate(std::ios_base::failbit); return stream; } - friend std::ostream& operator<<(std::ostream& stream, this_type const& dir) + friend std::ostream& operator<<(std::ostream& stream, this_type const& chg) { - return stream << (dir.value_ == up ? "up" : dir.value_ == dn ? "dn" : "no"); + return stream << (chg.value_ == up ? "up" : chg.value_ == dn ? "dn" : "no"); } value_type value() const { return value_; } @@ -73,7 +73,7 @@ struct direction namespace boost { - template<> inline direction convert::create_storage() { return direction(direction::up); } + template<> inline direction allocate_storage() { return direction(direction::up); } } struct test diff --git a/test/test_convert.cpp b/test/test_convert.cpp index 5a65e8d..75d6ac0 100644 --- a/test/test_convert.cpp +++ b/test/test_convert.cpp @@ -14,7 +14,6 @@ using std::string; using std::wstring; -using boost::convert; template void @@ -66,9 +65,9 @@ main(int argc, char const* argv[]) // Testing lexical_cast-based converter. //////////////////////////////////////////////////////////////////////////// - int lc00 = convert::from(not_int_str, lcnv).value_or(-1); - int lc01 = convert::from(std_str, lcnv).value_or(-1); - int lc02 = convert::from(c_str, lcnv).value_or(-1); + 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); BOOST_TEST(lc00 == -1); // Failed conversion. No throw BOOST_TEST(lc01 == -11); @@ -81,12 +80,12 @@ main(int argc, char const* argv[]) // On failure returns the provided fallback value and DOES NOT THROW. //////////////////////////////////////////////////////////////////////////// - int a000 = convert::from(not_int_str, ccnv).value_or(-1); - int a001 = convert::from(std_str, ccnv).value_or(-1); - int a002 = convert::from(c_str, ccnv).value_or(-1); - int a003 = convert::from(wstd_str, wcnv).value_or(-1); - int a004 = convert::from(wc_str, wcnv).value_or(-1); - int a005 = convert::from(array_str, ccnv).value_or(-1); + 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); BOOST_TEST(a000 == -1); // Failed conversion BOOST_TEST(a001 == -11); @@ -97,17 +96,17 @@ main(int argc, char const* argv[]) //////////////////////////////////////////////////////////////////////////// // Testing with the fallback value value provided. - // Testing implicit conversion to convert::result. - // convert<>::result exhibits the SAME behavior, i.e. + // Testing implicit conversion to boost::cnv::result. + // boost::cnv<>::result exhibits the SAME behavior, i.e. // on failure it returns the provided fallback value and DOES NOT THROW. //////////////////////////////////////////////////////////////////////////// - convert::result r000 = convert::from(not_int_str, ccnv); - convert::result r001 = convert::from(std_str, ccnv); - convert::result r002 = convert::from(c_str, ccnv); - convert::result r003 = convert::from(wstd_str, wcnv); - convert::result r004 = convert::from(wc_str, wcnv); - convert::result r005 = convert::from(array_str, ccnv); + boost::convert::result r000 = boost::cnv(not_int_str, ccnv); + boost::convert::result r001 = boost::cnv(std_str, ccnv); + boost::convert::result r002 = boost::cnv(c_str, ccnv); + boost::convert::result r003 = boost::cnv(wstd_str, wcnv); + boost::convert::result r004 = boost::cnv(wc_str, wcnv); + boost::convert::result r005 = boost::cnv(array_str, ccnv); BOOST_TEST(!r000); // Failed conversion BOOST_TEST( r001 && r001.value() == -11); @@ -124,18 +123,18 @@ main(int argc, char const* argv[]) try { - convert::from(not_int_str, ccnv).value(); + boost::cnv(not_int_str, ccnv).value(); BOOST_TEST(!"failed to throw"); } catch (std::exception&) { // Expected behavior: received 'boost::convert failed' exception. All well. } - int a021 = convert::from(std_str, ccnv).value(); - int a022 = convert::from(c_str, ccnv).value(); - int a023 = convert::from(wstd_str, wcnv).value(); - int a024 = convert::from(wc_str, wcnv).value(); - int a025 = convert::from(array_str, ccnv).value(); + 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(); BOOST_TEST(a021 == -11); BOOST_TEST(a022 == -12); @@ -144,18 +143,18 @@ main(int argc, char const* argv[]) BOOST_TEST(a025 == -15); //////////////////////////////////////////////////////////////////////////// - // Testing convert<>::result interface. - // convert<>::result exhibits the SAME (but delayed) behavior, i.e. + // Testing boost::cnv<>::result interface. + // boost::cnv<>::result exhibits the SAME (but delayed) behavior, i.e. // for failed conversion it throws on an attempt to retrieve the value // as there is nothing to return. //////////////////////////////////////////////////////////////////////////// - convert::result r010 = convert::from(not_int_str, ccnv); - convert::result r011 = convert::from(std_str, ccnv); - convert::result r012 = convert::from(c_str, ccnv); - convert::result r013 = convert::from(wstd_str, wcnv); - convert::result r014 = convert::from(wc_str, wcnv); - convert::result r015 = convert::from(array_str, ccnv); + boost::convert::result r010 = boost::cnv(not_int_str, ccnv); + boost::convert::result r011 = boost::cnv(std_str, ccnv); + boost::convert::result r012 = boost::cnv(c_str, ccnv); + boost::convert::result r013 = boost::cnv(wstd_str, wcnv); + boost::convert::result r014 = boost::cnv(wc_str, wcnv); + boost::convert::result r015 = boost::cnv(array_str, ccnv); BOOST_TEST(!r010); // Failed conversion BOOST_TEST( r011 && r011.value() == -11); @@ -178,16 +177,16 @@ main(int argc, char const* argv[]) // containers as the fallback values. //////////////////////////////////////////////////////////////////////////// - string s001 = convert< string>::from(-5, ccnv).value_or(std_str); - string s002 = convert< string>::from(-5, ccnv).value_or(c_str); - wstring s003 = convert::from(-5, wcnv).value_or(wstd_str); - wstring s004 = convert::from(-5, wcnv).value_or(wc_str); - string s005 = convert< string>::from(-5, ccnv).value_or(array_str); - convert< string>::result rs001 = convert< string>::from(-5, ccnv); - convert< string>::result rs002 = convert< string>::from(-5, ccnv); - convert::result rs003 = convert::from(-5, wcnv); - convert::result rs004 = convert::from(-5, wcnv); - convert< string>::result rs005 = convert< string>::from(-5, ccnv); + 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::convert< string>::result rs001 = boost::cnv< string>(-5, ccnv); + boost::convert< string>::result rs002 = boost::cnv< string>(-5, ccnv); + boost::convert::result rs003 = boost::cnv(-5, wcnv); + boost::convert::result rs004 = boost::cnv(-5, wcnv); + boost::convert< string>::result rs005 = boost::cnv< string>(-5, ccnv); BOOST_TEST(s001 == "-5"); BOOST_TEST(rs001 && rs001.value() == "-5"); BOOST_TEST(s002 == "-5"); BOOST_TEST(rs002 && rs002.value() == "-5"); @@ -199,10 +198,10 @@ main(int argc, char const* argv[]) // Testing int-to-string conversion with no fallback value. //////////////////////////////////////////////////////////////////////////// - string s010 = convert< string>::from(-5, ccnv).value(); - wstring s011 = convert::from(-5, wcnv).value(); - convert< string>::result rs010 = convert< string>::from(-5, ccnv); - convert::result rs011 = convert::from(-5, wcnv); + string s010 = boost::cnv< string>(-5, ccnv).value(); + wstring s011 = boost::cnv(-5, wcnv).value(); + boost::convert< string>::result rs010 = boost::cnv< string>(-5, ccnv); + boost::convert::result rs011 = boost::cnv(-5, wcnv); BOOST_TEST( s010 == "-5"); BOOST_TEST( s011 == L"-5"); @@ -215,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 = convert::from(direction::up, ccnv).value(); - string dn_dir0_str = convert::from(direction::dn, ccnv).value(); - string up_dir1_str = convert::from(up_dir1, ccnv).value(); - string dn_dir1_str = convert::from(dn_dir1, ccnv).value(); - direction up_dir2 = convert::from(up_dir1_str, ccnv).value(); - direction dn_dir2 = convert::from(dn_dir1_str, ccnv).value(); - direction up_dir3 = convert::from(up_dir1_str, ccnv).value(); - direction dn_dir3 = convert::from(dn_dir1_str, ccnv).value(); - direction dn_dir4 = convert::from("junk", ccnv).value_or(direction::dn); - convert::result up_dir4 = convert::from("junk", ccnv); + 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::convert::result up_dir4 = boost::cnv("junk", ccnv); BOOST_TEST(up_dir0_str == "up"); BOOST_TEST(dn_dir0_str == "dn"); @@ -250,10 +249,10 @@ main(int argc, char const* argv[]) { } - int hex_v01 = convert::from("FF", ccnv(std::hex)).value_or(0); - int hex_v02 = convert::from(L"F", wcnv(std::hex)).value_or(0); - int hex_v03 = convert::from("FF", ccnv(std::dec)).value_or(-5); - int hex_v04 = convert::from(L"F", wcnv(std::dec)).value_or(-5); + 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); BOOST_TEST(hex_v01 == 255); // "FF" BOOST_TEST(hex_v02 == 15); // L"F" @@ -262,8 +261,8 @@ main(int argc, char const* argv[]) ccnv(std::showbase)(std::uppercase)(std::hex); - BOOST_TEST(convert::from(255, ccnv).value() == "0XFF"); - BOOST_TEST(convert::from( 15, ccnv).value() == "0XF"); + BOOST_TEST(boost::cnv(255, ccnv).value() == "0XFF"); + BOOST_TEST(boost::cnv( 15, ccnv).value() == "0XF"); char const* double_s01 = test::is_msc ? "1.2345E-002" : test::is_gcc ? "1.2345E-02" @@ -273,15 +272,17 @@ main(int argc, char const* argv[]) (arg::uppercase = true) (arg::notation = cnv::notation::scientific); - double double_v01 = convert::from(double_s01, ccnv).value(); - string double_s02 = convert::from(double_v01, ccnv).value(); + double double_v01 = boost::cnv(double_s01, ccnv).value(); + string double_s02 = boost::cnv(double_v01, ccnv).value(); BOOST_TEST(double_s01 == double_s02); //////////////////////////////////////////////////////////////////////////// // Testing locale //////////////////////////////////////////////////////////////////////////// - + char const* eng_locale_name = test::is_msc ? "" // I do not know MCS presentation of US locale + : test::is_gcc ? "en_US.UTF-8" + : ""; char const* rus_locale_name = test::is_msc ? "Russian_Russia.1251" : test::is_gcc ? "ru_RU.UTF-8" : ""; @@ -290,22 +291,17 @@ main(int argc, char const* argv[]) std::locale rus_locale; std::locale eng_locale; - try - { - rus_locale = std::locale(rus_locale_name); - eng_locale = std::locale(""); - } - catch (...) - { - printf("Test failed: bad locale %s.\n", rus_locale_name); - exit(1); - } + try { rus_locale = std::locale(rus_locale_name); } + catch (...) { printf("Test failed: bad locale %s.\n", rus_locale_name); exit(1); } + + try { eng_locale = std::locale(eng_locale_name); } + catch (...) { printf("Test failed: bad locale %s.\n", eng_locale_name); exit(1); } // ccnv(std::setprecision(3))(std::nouppercase); ccnv(arg::precision = 3)(arg::uppercase = false); - string double_rus = convert::from(double_v01, ccnv(rus_locale)).value(); - string double_eng = convert::from(double_v01, ccnv(eng_locale)).value(); + string double_rus = boost::cnv(double_v01, ccnv(rus_locale)).value(); + string double_eng = boost::cnv(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()); @@ -316,13 +312,13 @@ main(int argc, char const* argv[]) // Testing string-to-bool and bool-to-string conversions //////////////////////////////////////////////////////////////////////////// -// convert::result bool_res1 = convert::from("1", false, ccnv); -// convert::result bool_res2 = convert::from("true", false, ccnv); -// convert::result bool_res3 = convert::from("yes", false, ccnv); -// convert::result bool_res4 = convert::from(L"1", false, wcnv); -// convert::result bool_res5 = convert::from(L"true", false, wcnv); -// convert::result bool_res6 = convert::from(L"yes", false, wcnv); -// convert::result bool_res7 = convert::from("junk", true, ccnv); +// boost::convert::result bool_res1 = boost::cnv("1", false, ccnv); +// boost::convert::result bool_res2 = boost::cnv("true", false, ccnv); +// boost::convert::result bool_res3 = boost::cnv("yes", false, ccnv); +// boost::convert::result bool_res4 = boost::cnv(L"1", false, wcnv); +// boost::convert::result bool_res5 = boost::cnv(L"true", false, wcnv); +// boost::convert::result bool_res6 = boost::cnv(L"yes", false, wcnv); +// boost::convert::result bool_res7 = boost::cnv("junk", true, ccnv); // // BOOST_TEST( bool_res1 && bool_res1.value() == true); // BOOST_TEST( bool_res2 && bool_res2.value() == true); @@ -332,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 = convert::from(true, ccnv).value_or("failed"); -// string bool_str2 = convert::from(false, ccnv).value_or("failed"); -// string bool_str3 = convert::from(1, ccnv).value_or("failed"); -// string bool_str4 = convert::from(0, ccnv).value_or("failed"); +// 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"); // // BOOST_TEST(bool_str1 == "1"); // BOOST_TEST(bool_str2 == "0");