Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53682 - in trunk: boost boost/variant libs/variant/doc/reference libs/variant/test
From: daniel_james_at_[hidden]
Date: 2009-06-06 07:46:25


Author: danieljames
Date: 2009-06-06 07:46:24 EDT (Sat, 06 Jun 2009)
New Revision: 53682
URL: http://svn.boost.org/trac/boost/changeset/53682

Log:
Support BOOST_NO_TYPEID and BOOST_NO_IOSTREAM in Boost.Variant. Fixes #3051.
Text files modified:
   trunk/boost/blank.hpp | 8 +++++++-
   trunk/boost/variant/variant.hpp | 13 +++++++++++++
   trunk/libs/variant/doc/reference/variant.xml | 11 +++++++++++
   trunk/libs/variant/test/jobs.h | 27 ++++-----------------------
   trunk/libs/variant/test/test3.cpp | 2 ++
   5 files changed, 37 insertions(+), 24 deletions(-)

Modified: trunk/boost/blank.hpp
==============================================================================
--- trunk/boost/blank.hpp (original)
+++ trunk/boost/blank.hpp 2009-06-06 07:46:24 EDT (Sat, 06 Jun 2009)
@@ -15,9 +15,11 @@
 
 #include "boost/blank_fwd.hpp"
 
+#if !defined(BOOST_NO_IOSTREAM)
 #include <iosfwd> // for std::basic_ostream forward declare
-
 #include "boost/detail/templated_streams.hpp"
+#endif // BOOST_NO_IOSTREAM
+
 #include "boost/mpl/bool.hpp"
 #include "boost/type_traits/is_empty.hpp"
 #include "boost/type_traits/is_pod.hpp"
@@ -85,6 +87,8 @@
 
 // streaming support
 //
+#if !defined(BOOST_NO_IOSTREAM)
+
 BOOST_TEMPLATED_STREAM_TEMPLATE(E,T)
 inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
       BOOST_TEMPLATED_STREAM(ostream, E,T)& out
@@ -95,6 +99,8 @@
     return out;
 }
 
+#endif // BOOST_NO_IOSTREAM
+
 } // namespace boost
 
 #endif // BOOST_BLANK_HPP

Modified: trunk/boost/variant/variant.hpp
==============================================================================
--- trunk/boost/variant/variant.hpp (original)
+++ trunk/boost/variant/variant.hpp 2009-06-06 07:46:24 EDT (Sat, 06 Jun 2009)
@@ -15,7 +15,10 @@
 
 #include <cstddef> // for std::size_t
 #include <new> // for placement new
+
+#if !defined(BOOST_NO_TYPEID)
 #include <typeinfo> // for typeid, std::type_info
+#endif // BOOST_NO_TYPEID
 
 #include "boost/variant/detail/config.hpp"
 #include "boost/mpl/aux_/config/eti.hpp"
@@ -691,6 +694,9 @@
 //
 // Generic static visitor that performs a typeid on the value it visits.
 //
+
+#if !defined(BOOST_NO_TYPEID)
+
 class reflect
     : public static_visitor<const std::type_info&>
 {
@@ -704,6 +710,8 @@
 
 };
 
+#endif // BOOST_NO_TYPEID
+
 ///////////////////////////////////////////////////////////////////////////////
 // (detail) class comparer
 //
@@ -1627,11 +1635,13 @@
         return false;
     }
 
+#if !defined(BOOST_NO_TYPEID)
     const std::type_info& type() const
     {
         detail::variant::reflect visitor;
         return this->apply_visitor(visitor);
     }
+#endif
 
 public: // prevent comparison with foreign types
 
@@ -1823,6 +1833,9 @@
 } // namespace boost
 
 // implementation additions
+
+#if !defined(BOOST_NO_IOSTREAM)
 #include "boost/variant/detail/variant_io.hpp"
+#endif // BOOST_NO_IOSTREAM
 
 #endif // BOOST_VARIANT_VARIANT_HPP

Modified: trunk/libs/variant/doc/reference/variant.xml
==============================================================================
--- trunk/libs/variant/doc/reference/variant.xml (original)
+++ trunk/libs/variant/doc/reference/variant.xml 2009-06-06 07:46:24 EDT (Sat, 06 Jun 2009)
@@ -364,6 +364,11 @@
           </returns>
 
           <throws>Will not throw.</throws>
+
+ <notes>
+ <simpara>Not available when <code>BOOST_NO_TYPEID</code> is
+ defined.</simpara>
+ </notes>
         </method>
 
       </method-group>
@@ -536,6 +541,12 @@
         <simpara>Calls <code>out &lt;&lt; x</code>, where <code>x</code> is
           the content of <code>rhs</code>.</simpara>
       </effects>
+
+ <notes>
+ <simpara>Not available when <code>BOOST_NO_IOSTREAM</code> is
+ defined.</simpara>
+ </notes>
+
     </function>
     
     <class name="make_variant_over">

Modified: trunk/libs/variant/test/jobs.h
==============================================================================
--- trunk/libs/variant/test/jobs.h (original)
+++ trunk/libs/variant/test/jobs.h 2009-06-06 07:46:24 EDT (Sat, 06 Jun 2009)
@@ -232,29 +232,6 @@
 
 
 
-
-struct held_type_name : boost::static_visitor<std::string>
-{
-
- template<typename T>
- std::string operator()(const T& ) const
- {
- ost_ << '[' << typeid(T).name() << ']';
- return result();
- }
-
- std::string result() const
- {
- return ost_.str();
- }
-
- mutable std::ostringstream ost_;
-
-}; //held_type_name
-
-
-
-
 template<typename T>
 struct spec
 {
@@ -267,7 +244,9 @@
    const VariantType& cvar = var;
 
    BOOST_CHECK(boost::apply_visitor(total_sizeof(), cvar) == sizeof(S));
+#if !defined(BOOST_NO_TYPEID)
    BOOST_CHECK(cvar.type() == typeid(S));
+#endif
 
    //
    // Check get<>()
@@ -316,7 +295,9 @@
 {
    const VariantType& cvar = var;
 
+#if !defined(BOOST_NO_TYPEID)
    BOOST_CHECK(cvar.type() != typeid(S));
+#endif
 
    //
    // Check get<>()

Modified: trunk/libs/variant/test/test3.cpp
==============================================================================
--- trunk/libs/variant/test/test3.cpp (original)
+++ trunk/libs/variant/test/test3.cpp 2009-06-06 07:46:24 EDT (Sat, 06 Jun 2009)
@@ -122,7 +122,9 @@
    std::ostringstream e1_str;
    e1_str << e1;
 
+#if !defined(BOOST_NO_TYPEID)
    BOOST_CHECK(e1.type() == typeid(Add));
+#endif
    BOOST_CHECK(e1_str.str() == "(13+((40+2)-(10+4)))");
 
    //Evaluate expression


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