#include /* The drain algorithm is similar to the boost::iostreams::copy algorithm, except that it does not close the Sink. */ namespace boost { namespace iostreams { namespace detail { template std::streamsize drain_impl(Source src, Sink snk, std::streamsize buffer_size) { using namespace std; typedef typename char_type_of::type src_char; typedef typename char_type_of::type snk_char; BOOST_STATIC_ASSERT((is_same::value)); bool nothrow = false; external_closer close_source(src, BOOST_IOS::in, nothrow); // Do not close the sink! // external_closer close_sink(snk, BOOST_IOS::out, nothrow); streamsize result = copy_impl( src, snk, buffer_size, is_direct(), is_direct() ); return result; } } // End namespace detail. //------------------Definition of drain----------------------------------------// template std::streamsize drain( const Source& src, const Sink& snk, std::streamsize buffer_size = default_device_buffer_size BOOST_IOSTREAMS_DISABLE_IF_STREAM(Source) BOOST_IOSTREAMS_DISABLE_IF_STREAM(Sink) ) { typedef typename char_type_of::type char_type; return detail::drain_impl( detail::resolve(src), detail::resolve(snk), buffer_size ); } #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------// template std::streamsize drain( Source& src, const Sink& snk, std::streamsize buffer_size = default_device_buffer_size BOOST_IOSTREAMS_ENABLE_IF_STREAM(Source) BOOST_IOSTREAMS_DISABLE_IF_STREAM(Sink) ) { typedef typename char_type_of::type char_type; return detail::drain_impl( detail::wrap(src), detail::resolve(snk), buffer_size ); } template std::streamsize drain( const Source& src, Sink& snk, std::streamsize buffer_size = default_device_buffer_size BOOST_IOSTREAMS_DISABLE_IF_STREAM(Source) BOOST_IOSTREAMS_ENABLE_IF_STREAM(Sink) ) { typedef typename char_type_of::type char_type; return detail::drain_impl( detail::resolve(src), detail::wrap(snk), buffer_size); } template std::streamsize drain( Source& src, Sink& snk, std::streamsize buffer_size = default_device_buffer_size BOOST_IOSTREAMS_ENABLE_IF_STREAM(Source) BOOST_IOSTREAMS_ENABLE_IF_STREAM(Sink) ) { return detail::drain_impl(detail::wrap(src), detail::wrap(snk), buffer_size); } #endif // #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //-----------------------// } // End of namespace iostreams } //End of namespace Boost