$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: jefffaust_at_[hidden]
Date: 2007-05-27 19:25:58
Author: jefffaust
Date: 2007-05-27 19:25:57 EDT (Sun, 27 May 2007)
New Revision: 4323
URL: http://svn.boost.org/trac/boost/changeset/4323
Log:
Add wrapper to support boost.range
Text files modified: 
   sandbox/explore/boost/explore/stream_container.hpp |    24 ++++++++++++++++++++++++                
   1 files changed, 24 insertions(+), 0 deletions(-)
Modified: sandbox/explore/boost/explore/stream_container.hpp
==============================================================================
--- sandbox/explore/boost/explore/stream_container.hpp	(original)
+++ sandbox/explore/boost/explore/stream_container.hpp	2007-05-27 19:25:57 EDT (Sun, 27 May 2007)
@@ -15,6 +15,7 @@
 #include <ostream>
 #include <boost/functional/detail/container_fwd.hpp>
 #include <boost/array.hpp>
+#include <boost/range/iterator_range.hpp>
 
 // generate string init functions for both char and wchar_t types
 #define BOOST_EXPLORE_INIT_STRING(name, str)                             \
@@ -96,6 +97,15 @@
         {
             explore::get_stream_state<container_stream_state<Elem, Tr> >(ostr)->assoc_end = end;
         }
+
+        // used to work around some problems with overriding for operator<<, in particular where
+        // there already exists such an operator that does not do what we want.
+        template<typename T>
+        struct iterator_range_wrapper
+        {
+            iterator_range_wrapper(const boost::iterator_range<T>& ir) : t(ir) {}
+            const boost::iterator_range<T>& t;
+        };
     }
 
     // A simple collection of additional stream state
@@ -178,6 +188,12 @@
         // redirect with "normal" streaming.
         return stream_container(ostr, first, last, stream_normal_value());
     }
+
+    template<typename T>
+    detail::iterator_range_wrapper<T> as_container(const boost::iterator_range<T>& ir)
+    {
+        return detail::iterator_range_wrapper<T>(ir);
+    }
 }
 
 namespace std
@@ -259,6 +275,14 @@
     }
 #   endif
 
+    // stream boost::iterator_range
+    template<typename Elem, typename Tr, typename T>
+    std::basic_ostream<Elem, Tr>& operator<<(std::basic_ostream<Elem, Tr>& ostr, 
+    explore::detail::iterator_range_wrapper<T>& r)
+    {
+        return explore::stream_container(ostr, r.t.begin(), r.t.end());
+    }
+
     // manipulator
     template<typename Elem>
     detail::manipfunc<Elem> separator(const Elem* sep)