|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72947 - sandbox/conversion/libs/conversion_ext/example
From: vicente.botet_at_[hidden]
Date: 2011-07-06 21:52:14
Author: viboes
Date: 2011-07-06 21:52:13 EDT (Wed, 06 Jul 2011)
New Revision: 72947
URL: http://svn.boost.org/trac/boost/changeset/72947
Log:
conversion: update comments
Text files modified:
sandbox/conversion/libs/conversion_ext/example/fallback.cpp | 19 +++++++++++++++++--
sandbox/conversion/libs/conversion_ext/example/no_throw.cpp | 5 +++++
sandbox/conversion/libs/conversion_ext/example/overload.cpp | 5 +++--
3 files changed, 25 insertions(+), 4 deletions(-)
Modified: sandbox/conversion/libs/conversion_ext/example/fallback.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/example/fallback.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/example/fallback.cpp 2011-07-06 21:52:13 EDT (Wed, 06 Jul 2011)
@@ -13,14 +13,16 @@
#include <boost/conversion/include.hpp>
#include <boost/conversion/std/string.hpp>
#include <iostream>
+#include <boost/assert.hpp>
using namespace boost::conversion;
void try_assign_to_way()
{
- std::string str="not an int";
//[FALLBACK_CPP_TRY_ASSIGN_WAY
+ std::string str="not an int";
int t=-1;
try_assign_to(t,str);
+ BOOST_ASSERT(t==-1);
//]
}
@@ -28,7 +30,19 @@
{
std::string str="not an int";
//[FALLBACK_CPP_CONVERT_TO_OR_FALLBACK
- int t = convert_to_or_fallback<int>(str,-1);
+ short f=-1;
+ int t = convert_to_or_fallback<int>(str,f);
+ BOOST_ASSERT(t==-1);
+ //]
+ (void)t;// remove warning: unused variable
+}
+
+void convert_to_or_fallback_way_deduced()
+{
+ std::string str="not an int";
+ //[FALLBACK_CPP_CONVERT_TO_OR_FALLBACK_DEDUCED
+ int t = convert_to_or_fallback(str,-1);
+ BOOST_ASSERT(t==-1);
//]
(void)t;// remove warning: unused variable
}
@@ -38,6 +52,7 @@
try_assign_to_way();
convert_to_or_fallback_way();
+ convert_to_or_fallback_way_deduced();
return 0;
}
Modified: sandbox/conversion/libs/conversion_ext/example/no_throw.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/example/no_throw.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/example/no_throw.cpp 2011-07-06 21:52:13 EDT (Wed, 06 Jul 2011)
@@ -13,6 +13,7 @@
#include <boost/conversion/include.hpp>
#include <boost/conversion/std/string.hpp>
#include <iostream>
+#include <boost/assert.hpp>
using boost::optional;
using namespace boost::conversion;
@@ -24,6 +25,7 @@
int t;
try {
t = convert_to<int>(str);
+ BOOST_ASSERT(false);
} catch(...) {
std::cout << " Not an integer" << std::endl;
}
@@ -37,6 +39,7 @@
if (!optt)
{
std::cout << " Not an integer" << std::endl;
+ BOOST_ASSERT(true);
}
//]
}
@@ -49,6 +52,7 @@
if (!optt)
{
std::cout << " Not an integer" << std::endl;
+ BOOST_ASSERT(true);
}
//]
}
@@ -61,6 +65,7 @@
if (!try_assign_to(t,str))
{
std::cout << " Not an integer" << std::endl;
+ BOOST_ASSERT(true);
}
//]
}
Modified: sandbox/conversion/libs/conversion_ext/example/overload.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/example/overload.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/example/overload.cpp 2011-07-06 21:52:13 EDT (Wed, 06 Jul 2011)
@@ -14,6 +14,7 @@
//#include <boost/conversion/std/string.hpp>
#include <string>
#include <iostream>
+#include <boost/assert.hpp>
#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
@@ -148,15 +149,15 @@
void mcf_extrinsic_test()
{
- //[OVERLOAD_CPP_MCF
#if defined(BOOST_CONVERSION_MCF_ENABLED)
+ //[OVERLOAD_CPP_MCF
McfTest<IntrCvtToInt>::whichOverload();
McfTest<IntrCvtToString>::whichOverload();
McfTest<ExtrCvtToInt>::whichOverload();
McfTest<ExtrCvtToString>::whichOverload();
-#endif
//McfTest<ExtrCvtINtAndString>::whichOverload(); // compile fail
//]
+#endif
#if 0
//[OVERLOAD_CPP_MCF_EXPLICIT
McfTest<ExtrExplicitCvtToInt>::whichOverload();
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk