Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73243 - sandbox/conversion/libs/conversion_ext/example
From: vicente.botet_at_[hidden]
Date: 2011-07-19 17:54:03


Author: viboes
Date: 2011-07-19 17:54:02 EDT (Tue, 19 Jul 2011)
New Revision: 73243
URL: http://svn.boost.org/trac/boost/changeset/73243

Log:
conversion: cleanup
Removed:
   sandbox/conversion/libs/conversion_ext/example/formatted.cpp
Text files modified:
   sandbox/conversion/libs/conversion_ext/example/overload.cpp | 20 ++++++++++----------
   sandbox/conversion/libs/conversion_ext/example/swap.cpp | 2 --
   2 files changed, 10 insertions(+), 12 deletions(-)

Deleted: sandbox/conversion/libs/conversion_ext/example/formatted.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/example/formatted.cpp 2011-07-19 17:54:02 EDT (Tue, 19 Jul 2011)
+++ (empty file)
@@ -1,129 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-//[FORMATTED_CPP
-
-#include <boost/conversion/std/string.hpp>
-#include <boost/conversion/convert_to_or_fallback.hpp>
-#include <string>
-#include <iomanip>
-#include <boost/assert.hpp>
-
-class extract_t { };
-const extract_t extract={};
-
-
-template <typename T>
-class extractor_stream {
- std::stringstream ios_;
- T value_;
-
-public:
-
- template<typename U>
- extractor_stream& operator<< (U u) { return (ios_ << u, *this); }
-
- template<typename U>
- extractor_stream& operator>> (U u) { return (ios_ >> u, *this); }
-
-
- T operator>> (extract_t const&) {
- T value;
- ios_ >> value;
- return value;
- }
-
-};
-
-template <typename T>
-class extract_to { };
-
-class via_stream {
- std::stringstream ios_;
-
-public:
-
- template<typename U>
- via_stream& operator<< (U u) { return (ios_ << u, *this); }
-
- template<typename U>
- via_stream& operator>> (U u) { return (ios_ >> u, *this); }
-
-
- template<typename T>
- T operator>> (extract_to<T> const&) {
- T value;
- ios_ >> value;
- return value;
- }
-
-};
-
-
-
-int main()
-{
- {
- using namespace boost::conversion;
- {
- std::string hex_str = "0xFF"; // 255 in decimal
- // This call fails
- int bad = convert_to_or_fallback<int>(hex_str, -1);
- BOOST_ASSERT(bad == -1); // Failed decimal conversion from "FF"
- }
- {
-
- std::string hex_str = "FF"; // 255 in decimal
-
- // This call also fails
- int bad = convert_to_or_fallback<int>(hex_str, -1);
- BOOST_ASSERT(bad == -1); // Failed decimal conversion from "FF"
-
- // Apply hex formatting while converting from string
- int ii = extractor_stream<int>() << hex_str >> std::hex >> extract;
- BOOST_ASSERT(ii == 255); // Successful hex conversion from "FF"
-
- // Apply hex formatting while converting from string
- int iii = via_stream()
- << hex_str
- >> std::hex >> extract_to<int>();
-
- BOOST_ASSERT(iii == 255); // Successful hex conversion from "FF"
-
- std::string si1 = via_stream()
- << std::uppercase << std::hex << ii
- >> extract_to<std::string>();
-
- BOOST_ASSERT(si1 == "FF");
-
-
- // Apply hex, uppercase, showbase formatting while converting to string
- std::string si2 = via_stream()
- << std::showbase << std::uppercase << std::hex << ii
- >> extract_to<std::string>();
-
- BOOST_ASSERT(si2 == "0XFF");
-
- std::string double_str = "1.2345e-02";
- double d = via_stream() << double_str
- >> extract_to<double>();
-
- std::string sd= via_stream()
- << std::setprecision(4) << std::scientific << d
- >> extract_to<std::string>();
-
- BOOST_ASSERT(sd == double_str);
- }
- }
-
- return 0;
-}
-
-//]

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-19 17:54:02 EDT (Tue, 19 Jul 2011)
@@ -114,9 +114,9 @@
   }
 }
 
-//[OVERLOAD_CPP_MCF_LIKE
+//[OVERLOAD_CPP_IMPLICITLY_LIKE
 template <typename T>
-struct McfTest {
+struct ImplicitlyTest {
   static void whichOverload()
   {
     T v;
@@ -149,18 +149,18 @@
 
 void implicitly_extrinsic_test()
 {
-#if defined(BOOST_CONVERSION_MCF_ENABLED)
- //[OVERLOAD_CPP_MCF
+#if defined(BOOST_CONVERSION_IMPLICITLY_ENABLED)
+ //[OVERLOAD_CPP_IMPLICITLY
   McfTest<IntrCvtToInt>::whichOverload();
- McfTest<IntrCvtToString>::whichOverload();
- McfTest<ExtrCvtToInt>::whichOverload();
- McfTest<ExtrCvtToString>::whichOverload();
- //McfTest<ExtrCvtINtAndString>::whichOverload(); // compile fail
+ ImplicitlyTest<IntrCvtToString>::whichOverload();
+ ImplicitlyTest<ExtrCvtToInt>::whichOverload();
+ ImplicitlyTest<ExtrCvtToString>::whichOverload();
+ //ImplicitlyTest<ExtrCvtINtAndString>::whichOverload(); // compile fail
   //]
 #endif
   #if 0
- //[OVERLOAD_CPP_MCF_EXPLICIT
- McfTest<ExtrExplicitCvtToInt>::whichOverload();
+ //[OVERLOAD_CPP_IMPLICITLY_EXPLICIT
+ ImplicitlyTest<ExtrExplicitCvtToInt>::whichOverload();
   //]
   #endif
 }

Modified: sandbox/conversion/libs/conversion_ext/example/swap.cpp
==============================================================================
--- sandbox/conversion/libs/conversion_ext/example/swap.cpp (original)
+++ sandbox/conversion/libs/conversion_ext/example/swap.cpp 2011-07-19 17:54:02 EDT (Tue, 19 Jul 2011)
@@ -29,9 +29,7 @@
       std::cout << "i= " << i << std::endl;
       std::cout << "x= " << x << std::endl;
 
-#if defined(BOOST_CONVERSION_ENABLE_CND)
       swap_convertibles(i, x);
-#endif
 
       std::cout << "i= " << i << std::endl;
       std::cout << "x= " << x << std::endl;


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