From d18e2b08bdf492a2f44e136a571b14df1f88f2ba Mon Sep 17 00:00:00 2001 From: Jonathan Turkanis Date: Fri, 4 Feb 2005 21:47:58 +0000 Subject: [PATCH] replaced use of scope_guard with closer [SVN r27122] --- .../iostreams/filter/one_step_filter.hpp | 15 ++++------ .../filter/symmetric_filter_adapter.hpp | 29 +++++++++---------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/include/boost/iostreams/filter/one_step_filter.hpp b/include/boost/iostreams/filter/one_step_filter.hpp index 1a2faa5..a5627c0 100755 --- a/include/boost/iostreams/filter/one_step_filter.hpp +++ b/include/boost/iostreams/filter/one_step_filter.hpp @@ -18,10 +18,8 @@ #include // openmode. #include // back_inserter #include -#include // Used w/ scope_guard. -#include // Used w/ scope_guard. #include -#include +#include namespace boost { namespace iostreams { @@ -71,16 +69,16 @@ public: data_.insert(data_.end(), s, s + n); } - #include // CW workaround + typedef one_step_filter self; + friend struct detail::closer; template void close(Sink& sink, std::ios::openmode which) { if ((state_ & f_read) && (which & std::ios::in)) - close_impl(); + close(); if ((state_ & f_write) && (which & std::ios::out)) { - typedef one_step_filter self; - BOOST_SCOPE_GUARD(boost::bind(&self::close_impl, boost::ref(*this))); + detail::closer closer(*this); vector_type filtered; do_filter(data_, filtered); boost::iostreams::write( @@ -89,7 +87,6 @@ public: ); } } - #include protected: typedef std::vector vector_type; @@ -111,7 +108,7 @@ private: state_ |= f_eof; } - void close_impl() + void close() { data_.clear(); ptr_ = 0; diff --git a/include/boost/iostreams/filter/symmetric_filter_adapter.hpp b/include/boost/iostreams/filter/symmetric_filter_adapter.hpp index cb33d05..38bcf89 100755 --- a/include/boost/iostreams/filter/symmetric_filter_adapter.hpp +++ b/include/boost/iostreams/filter/symmetric_filter_adapter.hpp @@ -38,15 +38,13 @@ #include // MSVC. #include -#include // allocator -#include // Used w/ scope_guard. -#include // Used w/ scope_guard. -#include // buffer size. -#include // buffer size. +#include // allocator +#include // BOOST_DEDUCED_TYPENAME. +#include // buffer size. #include -#include +#include #include -#include // read, write. +#include // read, write. #include namespace boost { namespace iostreams { @@ -122,7 +120,8 @@ public: } } - #include // CW workaround. + typedef symmetric_filter_adapter_impl self; + friend struct closer; template void close(Sink& snk, std::ios::openmode which) { @@ -130,11 +129,8 @@ public: if ((state_ & f_read) && (which & ios::in)) close(); if ((state_ & f_write) && (which & ios::out)) { - void (symmetric_filter_adapter_impl::*close) () = - &symmetric_filter_adapter_impl::close; - BOOST_SCOPE_GUARD(bind(close, ref(*this))); - - char e; // Dummy. + closer closer(*this); + char e; // Dummy. const char* end = &e; bool done = false; flush(snk); @@ -146,7 +142,6 @@ public: } } } - #include SymmetricFilter& filter() { return *filter_; } string_type unconsumed_input() const; @@ -180,7 +175,11 @@ private: } // End namespace detail. template< typename SymmetricFilter, - typename Alloc = std::allocator > + typename Alloc = + std::allocator< + BOOST_DEDUCED_TYPENAME + io_char::type + > > class symmetric_filter_adapter { private: typedef detail::symmetric_filter_adapter_impl<