1 // (C) Copyright Jonathan Turkanis 2003.
2 // Distributed under the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
5 // See http://www.boost.org/libs/iostreams for documentation.
7 #ifndef BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED
8 #define BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED
10 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
14 #include <boost/config.hpp> // DEDUCED_TYPENAME, MSVC.
15 #include <boost/detail/workaround.hpp>
16 #include <boost/iostreams/constants.hpp> // constants.
17 #include <boost/iostreams/detail/dispatch.hpp>
18 #include <boost/iostreams/detail/wrap_unwrap.hpp>
19 #include <boost/iostreams/operations_fwd.hpp>
20 #include <boost/mpl/if.hpp>
23 #include <boost/iostreams/detail/config/disable_warnings.hpp>
25 namespace boost { namespace iostreams {
30 struct optimal_buffer_size_impl;
32 } // End namespace detail.
35 std::streamsize optimal_buffer_size(const T& t)
37 typedef detail::optimal_buffer_size_impl<T> impl;
38 return impl::optimal_buffer_size(detail::unwrap(t));
43 //------------------Definition of optimal_buffer_size_impl--------------------//
46 struct optimal_buffer_size_impl
50 optimal_buffer_size_impl<
51 BOOST_DEDUCED_TYPENAME
53 T, optimally_buffered_tag, device_tag, filter_tag
60 struct optimal_buffer_size_impl<optimally_buffered_tag> {
62 static std::streamsize optimal_buffer_size(const T& t)
63 { return t.optimal_buffer_size(); }
67 struct optimal_buffer_size_impl<device_tag> {
69 static std::streamsize optimal_buffer_size(const T&)
70 { return default_device_buffer_size; }
74 struct optimal_buffer_size_impl<filter_tag> {
76 static std::streamsize optimal_buffer_size(const T&)
77 { return default_filter_buffer_size; }
80 } // End namespace detail.
82 } } // End namespaces iostreams, boost.
84 #include <boost/iostreams/detail/config/enable_warnings.hpp>
86 #endif // #ifndef BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED