Boost logo

Boost Users :

Subject: [Boost-users] [boost] [iostreams] Pipelined reference_wrappers of filters/device
From: feverzsj (feverzsj_at_[hidden])
Date: 2010-04-21 12:00:14


hi all,
  BOOST_IOSTREAMS_PIPABLE generate something like :
          template<..., typename component>
          pipeline<...> operator|(your_filter const& , component const&);
  It is proper for plan use, e.g. filter1 | filter2 | ... | device.
  But for boost::reference_wrapper, ref(filter1) | ref(filter2)
|...|ref(device), after type conversion, will be : filter1 | ref(filter2)
|...|ref(device), which may confuse the user.
  So, will it be a good idea to make another reloaded
operator|(reference_wrapper<your_filter> const&, component const&)) ?
  I have written a macro to handle this( simply copy and modify
BOOST_IOSTREAMS_PIPABLE):

#define BOOST_IOSTREAMS_EXTENDED_PIPABLE(filter, arity) \
template< BOOST_PP_ENUM_PARAMS(arity, typename T) \
                BOOST_PP_COMMA_IF(arity) typename Component> \
::boost::iostreams::pipeline< \
                ::boost::iostreams::detail::pipeline_segment<filter
BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)> \
                ,Component \
> \
operator|(const filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)& f, const
Component& c) \
{ \
        typedef \
                ::boost::iostreams::detail::pipeline_segment< \
                        filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T) \
> segment; \
        return ::boost::iostreams::pipeline<segment, Component> \
        (segment(f), c); \
} \
template<BOOST_PP_ENUM_PARAMS(arity, typename T) \
                BOOST_PP_COMMA_IF(arity)typename Component> \
::boost::iostreams::pipeline< \
                ::boost::iostreams::detail::pipeline_segment< \
                                                        boost::reference_wrapper<filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity,
T)> > \
                ,Component \
> \
operator|(const boost::reference_wrapper<filter
BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)>& wf \
                ,const Component& c) \
{ \
        typedef \
                ::boost::iostreams::detail::pipeline_segment< \
                        boost::reference_wrapper<filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)>
\
> segment; \
        return ::boost::iostreams::pipeline<segment, Component>(segment(wf), c);
\
} \
/**/

-- 
View this message in context: http://old.nabble.com/-boost---iostreams--Pipelined-reference_wrappers-of-filters-device-tp28288053p28288053.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net