// (C) Copyright Jonathan Turkanis 2003. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) // See http://www.boost.org/libs/iostreams for documentation. #ifndef BOOST_IOSTREAMS_CLOSE_HPP_INCLUDED #define BOOST_IOSTREAMS_CLOSE_HPP_INCLUDED #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include // DEDUCED_TYPENAME, MSVC. #include #include #include #include #include #include #include #include #include #include // Must come last. #include #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-----------------------------------// # include #else // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //--------------------------// namespace boost { namespace iostreams { namespace detail { template struct close_impl; } // End namespace detail. template void close(T& t, BOOST_IOS::openmode which) { detail::close_impl::close(detail::unwrap(t), which); } template void close(T& t, Sink& snk, BOOST_IOS::openmode which) { detail::close_impl::close(detail::unwrap(t), snk, which); } namespace detail { //------------------Definition of close_impl----------------------------------// template struct close_tag { typedef typename category_of::type category; typedef typename mpl::eval_if< is_convertible, mpl::if_< mpl::or_< is_convertible, is_convertible >, two_sequence, closable_tag >, mpl::identity >::type type; }; template struct close_impl : mpl::if_< is_custom, operations, close_impl::type> >::type { }; template<> struct close_impl { template static void close(T& t, BOOST_IOS::openmode which) { if ((which & BOOST_IOS::out) != 0) iostreams::flush(t); } template static void close(T& t, Sink& snk, BOOST_IOS::openmode which) { if ((which & BOOST_IOS::out) != 0) { non_blocking_adapter nb(snk); iostreams::flush(t, nb); } } }; #include // Borland. template<> struct close_impl { template static void close(T& t, BOOST_IOS::openmode which) { typedef typename category_of::type category; const bool in = is_convertible::value && !is_convertible::value; if (in == ((which & BOOST_IOS::in) != 0)) t.close(); } template static void close(T& t, Sink& snk, BOOST_IOS::openmode which) { typedef typename category_of::type category; const bool in = is_convertible::value && !is_convertible::value; if (in == ((which & BOOST_IOS::in) != 0)) { non_blocking_adapter nb(snk); t.close(nb); } } }; template<> struct close_impl { template static void close(T& t, BOOST_IOS::openmode which) { t.close(which); } template static void close(T& t, Sink& snk, BOOST_IOS::openmode which) { non_blocking_adapter nb(snk); t.close(nb, which); } }; } // End namespace detail. } } // End namespaces iostreams, boost. #endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-------------------------// #include #endif // #ifndef BOOST_IOSTREAMS_CLOSE_HPP_INCLUDED