1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
2 // (C) Copyright 2003-2007 Jonathan Turkanis
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
6 // See http://www.boost.org/libs/iostreams for documentation.
8 #ifndef BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED
11 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
15 #include <boost/config.hpp> // DEDUCED_TYPENAME, MSVC.
16 #include <boost/detail/workaround.hpp>
17 #include <boost/iostreams/detail/dispatch.hpp>
18 #include <boost/iostreams/detail/streambuf.hpp>
19 #include <boost/iostreams/detail/wrap_unwrap.hpp>
20 #include <boost/iostreams/operations_fwd.hpp>
21 #include <boost/iostreams/traits.hpp>
22 #include <boost/mpl/if.hpp>
25 #include <boost/iostreams/detail/config/disable_warnings.hpp>
27 namespace boost
{ namespace iostreams
{
32 struct flush_device_impl
;
35 struct flush_filter_impl
;
37 } // End namespace detail.
41 { return detail::flush_device_impl
<T
>::flush(detail::unwrap(t
)); }
43 template<typename T
, typename Sink
>
44 bool flush(T
& t
, Sink
& snk
)
45 { return detail::flush_filter_impl
<T
>::flush(detail::unwrap(t
), snk
); }
49 //------------------Definition of flush_device_impl---------------------------//
52 struct flush_device_impl
57 BOOST_DEDUCED_TYPENAME
59 T
, ostream_tag
, streambuf_tag
, flushable_tag
, any_tag
66 struct flush_device_impl
<ostream_tag
> {
68 static bool flush(T
& t
)
69 { return t
.rdbuf()->BOOST_IOSTREAMS_PUBSYNC() == 0; }
73 struct flush_device_impl
<streambuf_tag
> {
75 static bool flush(T
& t
)
76 { return t
.BOOST_IOSTREAMS_PUBSYNC() == 0; }
80 struct flush_device_impl
<flushable_tag
> {
82 static bool flush(T
& t
) { return t
.flush(); }
86 struct flush_device_impl
<any_tag
> {
88 static bool flush(T
&) { return true; }
91 //------------------Definition of flush_filter_impl---------------------------//
94 struct flush_filter_impl
99 BOOST_DEDUCED_TYPENAME
101 T
, flushable_tag
, any_tag
108 struct flush_filter_impl
<flushable_tag
> {
109 template<typename T
, typename Sink
>
110 static bool flush(T
& t
, Sink
& snk
) { return t
.flush(snk
); }
114 struct flush_filter_impl
<any_tag
> {
115 template<typename T
, typename Sink
>
116 static bool flush(T
&, Sink
&) { return false; }
119 } // End namespace detail.
121 } } // End namespaces iostreams, boost.
123 #include <boost/iostreams/detail/config/enable_warnings.hpp>
125 #endif // #ifndef BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED