Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2008-06-02 12:31:43


Author: turkanis
Date: 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
New Revision: 46047
URL: http://svn.boost.org/trac/boost/changeset/46047

Log:
in forward.hpp, disabled forwarding constructors and overloads of open when the first parameter is the same as the device type, to address #1671; removed unnecessary poilcy_type members; renamed remaining policy_type members to component_type or device_type, depending on the context
Text files modified:
   trunk/boost/iostreams/chain.hpp | 6 ++--
   trunk/boost/iostreams/code_converter.hpp | 12 ++++----
   trunk/boost/iostreams/detail/adapter/mode_adapter.hpp | 6 ++--
   trunk/boost/iostreams/detail/broken_overload_resolution/stream.hpp | 1
   trunk/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp | 1
   trunk/boost/iostreams/detail/forward.hpp | 58 +++++++++++++++++++++++++++------------
   trunk/boost/iostreams/stream.hpp | 1
   trunk/boost/iostreams/stream_buffer.hpp | 1
   8 files changed, 52 insertions(+), 34 deletions(-)

Modified: trunk/boost/iostreams/chain.hpp
==============================================================================
--- trunk/boost/iostreams/chain.hpp (original)
+++ trunk/boost/iostreams/chain.hpp 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
@@ -229,9 +229,9 @@
     void push_impl(const T& t, int buffer_size = -1, int pback_size = -1)
     {
         typedef typename iostreams::category_of<T>::type category;
- typedef typename unwrap_ios<T>::type policy_type;
+ typedef typename unwrap_ios<T>::type component_type;
         typedef stream_buffer<
- policy_type,
+ component_type,
                     BOOST_IOSTREAMS_CHAR_TRAITS(char_type),
                     Alloc, Mode
> streambuf_t;
@@ -252,7 +252,7 @@
             buf(new streambuf_t(t, buffer_size, pback_size));
         list().push_back(buf.get());
         buf.release();
- if (is_device<policy_type>::value) {
+ if (is_device<component_type>::value) {
             pimpl_->flags_ |= f_complete | f_open;
             for ( iterator first = list().begin(),
                            last = list().end();

Modified: trunk/boost/iostreams/code_converter.hpp
==============================================================================
--- trunk/boost/iostreams/code_converter.hpp (original)
+++ trunk/boost/iostreams/code_converter.hpp 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
@@ -138,8 +138,8 @@
                 is_direct<Device>,
                 direct_adapter<Device>,
                 Device
- >::type policy_type;
- typedef optional< concept_adapter<policy_type> > storage_type;
+ >::type device_type;
+ typedef optional< concept_adapter<device_type> > storage_type;
     typedef is_convertible<device_category, two_sequence> is_double;
     typedef conversion_buffer<Codecvt, Alloc> buffer_type;
 
@@ -168,7 +168,7 @@
             buf_.second().resize(buffer_size);
             buf_.second().set(0, 0);
         }
- dev_.reset(concept_adapter<policy_type>(dev));
+ dev_.reset(concept_adapter<device_type>(dev));
         flags_ = f_open;
     }
 
@@ -200,7 +200,7 @@
 
     bool is_open() const { return (flags_ & f_open) != 0;}
 
- policy_type& dev() { return **dev_; }
+ device_type& dev() { return **dev_; }
 
     enum flag_type {
         f_open = 1,
@@ -243,7 +243,7 @@
     typedef detail::code_converter_impl<
                 Device, Codecvt, Alloc
> impl_type;
- typedef typename impl_type::policy_type policy_type;
+ typedef typename impl_type::device_type device_type;
     typedef typename impl_type::buffer_type buffer_type;
     typedef typename detail::codecvt_holder<Codecvt>::codecvt_type codecvt_type;
     typedef typename detail::codecvt_intern<Codecvt>::type intern_type;
@@ -298,7 +298,7 @@
     }
 
     const codecvt_type& cvt() { return impl().cvt_.get(); }
- policy_type& dev() { return impl().dev(); }
+ device_type& dev() { return impl().dev(); }
     buffer_type& in() { return impl().buf_.first(); }
     buffer_type& out() { return impl().buf_.second(); }
     impl_type& impl() { return *this->pimpl_; }

Modified: trunk/boost/iostreams/detail/adapter/mode_adapter.hpp
==============================================================================
--- trunk/boost/iostreams/detail/adapter/mode_adapter.hpp (original)
+++ trunk/boost/iostreams/detail/adapter/mode_adapter.hpp 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
@@ -31,7 +31,7 @@
 private:
     struct empty_base { };
 public:
- typedef typename wrapped_type<T>::type policy_type;
+ typedef typename wrapped_type<T>::type component_type;
     typedef typename char_type_of<T>::type char_type;
     struct category
         : Mode,
@@ -43,7 +43,7 @@
           #endif
           localizable_tag
         { };
- explicit mode_adapter(const policy_type& t) : t_(t) { }
+ explicit mode_adapter(const component_type& t) : t_(t) { }
 
         // Device member functions.
 
@@ -88,7 +88,7 @@
     void imbue(const Locale& loc)
     { iostreams::imbue(t_, loc); }
 private:
- policy_type t_;
+ component_type t_;
 };
                     
 //------------------Implementation of mode_adapter----------------------------//

Modified: trunk/boost/iostreams/detail/broken_overload_resolution/stream.hpp
==============================================================================
--- trunk/boost/iostreams/detail/broken_overload_resolution/stream.hpp (original)
+++ trunk/boost/iostreams/detail/broken_overload_resolution/stream.hpp 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
@@ -35,7 +35,6 @@
             detail::stream_traits<
                 Device, Tr
>::stream_type stream_type;
- typedef Device policy_type;
 public:
     stream() { }
     template<typename U0>

Modified: trunk/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp
==============================================================================
--- trunk/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp (original)
+++ trunk/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
@@ -35,7 +35,6 @@
             detail::stream_buffer_traits<
                 T, Tr, Alloc, Mode
>::type base_type;
- typedef T policy_type;
 public:
     typedef typename char_type_of<T>::type char_type;
     struct category

Modified: trunk/boost/iostreams/detail/forward.hpp
==============================================================================
--- trunk/boost/iostreams/detail/forward.hpp (original)
+++ trunk/boost/iostreams/detail/forward.hpp 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
@@ -12,7 +12,7 @@
 # pragma once
 #endif
  
-#include <boost/config.hpp> // BOOST_MSVC
+#include <boost/config.hpp> // BOOST_MSVC, BOOST_NO_SFINAE
 #include <boost/detail/workaround.hpp>
 #include <boost/iostreams/detail/config/limits.hpp>
 #include <boost/iostreams/detail/push_params.hpp>
@@ -23,36 +23,43 @@
 #include <boost/preprocessor/repetition/enum_params.hpp>
 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
 #include <boost/preprocessor/tuple/elem.hpp>
+#include <boost/type_traits/is_same.hpp>
 
 //------Macros for defining forwarding constructors and open overloads--------//
     
 //
-// Macro: BOOST_IOSTREAMS_DEFINE_FORWARDING_FUNCTIONS(mode, name, helper).
+// Macro: BOOST_IOSTREAMS_FORWARD(class, impl, device, params, args)
 // Description: Defines constructors and overloads of 'open' which construct
-// a device using the given argument list and pass it to 'open_impl'.
-// Assumes that 'policy_type' is an alias for the device type.
-// Not supported on Intel 7.1 and VC6.5.
+// a device using the specified argument list and pass it to the specified
+// helper function
+// class - The class name
+// impl - The helper function
+// device - The device type
+// params - The list of formal parameters trailing the device parameter in
+// the helper function's signature
+// params - The list of arguments passed to the helper function, following the
+// device argument
 //
-#define BOOST_IOSTREAMS_FORWARD(class, impl, policy, params, args) \
- class(const policy& t params()) \
+#define BOOST_IOSTREAMS_FORWARD(class, impl, device, params, args) \
+ class(const device& t params()) \
     { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
- class(policy& t params()) \
+ class(device& t params()) \
     { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
- class(const ::boost::reference_wrapper<policy>& ref params()) \
+ class(const ::boost::reference_wrapper<device>& ref params()) \
     { this->impl(ref args()); } \
- void open(const policy& t params()) \
+ void open(const device& t params()) \
     { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
- void open(policy& t params()) \
+ void open(device& t params()) \
     { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
- void open(const ::boost::reference_wrapper<policy>& ref params()) \
+ void open(const ::boost::reference_wrapper<device>& ref params()) \
     { this->impl(ref args()); } \
     BOOST_PP_REPEAT_FROM_TO( \
         1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
- BOOST_IOSTREAMS_FORWARDING_CTOR, (class, impl, policy) \
+ BOOST_IOSTREAMS_FORWARDING_CTOR, (class, impl, device) \
     ) \
     BOOST_PP_REPEAT_FROM_TO( \
         1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
- BOOST_IOSTREAMS_FORWARDING_FN, (class, impl, policy) \
+ BOOST_IOSTREAMS_FORWARDING_FN, (class, impl, device) \
     ) \
     /**/
 #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
@@ -61,7 +68,8 @@
               BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
     BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
     ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
- BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u)) \
+ BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \
+ BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
     { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
       ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
         ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
@@ -72,7 +80,8 @@
               BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
     void open \
     ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
- BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u)) \
+ BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u) \
+ BOOST_IOSTREAMS_DISABLE_IF_SAME(U100, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
     { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
       ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
         BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u) ); } \
@@ -84,7 +93,8 @@
 #define BOOST_IOSTREAMS_FORWARDING_CTOR(z, n, tuple) \
     template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
     BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
- (BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u)) \
+ (BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
+ BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
     { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
       ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
         (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
@@ -92,11 +102,23 @@
     /**/
 #define BOOST_IOSTREAMS_FORWARDING_FN(z, n, tuple) \
     template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
- void open(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u)) \
+ void open(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u) \
+ BOOST_IOSTREAMS_DISABLE_IF_SAME(U0, BOOST_PP_TUPLE_ELEM(3, 2, tuple))) \
     { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
       ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
         (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
     BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \
     /**/
 
+// Disable forwarding constructors if first parameter type is the same
+// as the device type
+#if !defined(BOOST_NO_SFINAE) && \
+ !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
+# define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param) \
+ , typename boost::disable_if< boost::is_same<device, param> >::type* = 0 \
+ /**/
+#else
+# define BOOST_IOSTREAMS_DISABLE_IF_SAME(device, param)
+#endif
+
 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED

Modified: trunk/boost/iostreams/stream.hpp
==============================================================================
--- trunk/boost/iostreams/stream.hpp (original)
+++ trunk/boost/iostreams/stream.hpp 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
@@ -123,7 +123,6 @@
             detail::stream_traits<
                 Device, Tr
>::stream_type stream_type;
- typedef Device policy_type;
 public:
     stream() { }
     BOOST_IOSTREAMS_FORWARD( stream, open_impl, Device,

Modified: trunk/boost/iostreams/stream_buffer.hpp
==============================================================================
--- trunk/boost/iostreams/stream_buffer.hpp (original)
+++ trunk/boost/iostreams/stream_buffer.hpp 2008-06-02 12:31:42 EDT (Mon, 02 Jun 2008)
@@ -73,7 +73,6 @@
             detail::stream_buffer_traits<
                 T, Tr, Alloc, Mode
>::type base_type;
- typedef T policy_type;
 public:
     typedef typename char_type_of<T>::type char_type;
     struct category


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