File indexing completed on 2025-01-30 09:44:33
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED
0010
0011 #if defined(_MSC_VER)
0012 # pragma once
0013 #endif
0014
0015 #include <boost/config.hpp> // DEDUCED_TYPENAME, MSVC.
0016 #include <boost/detail/workaround.hpp>
0017 #include <boost/iostreams/constants.hpp> // constants.
0018 #include <boost/iostreams/detail/dispatch.hpp>
0019 #include <boost/iostreams/detail/wrap_unwrap.hpp>
0020 #include <boost/iostreams/operations_fwd.hpp>
0021 #include <boost/mpl/if.hpp>
0022
0023
0024 #include <boost/iostreams/detail/config/disable_warnings.hpp>
0025
0026 namespace boost { namespace iostreams {
0027
0028 namespace detail {
0029
0030 template<typename T>
0031 struct optimal_buffer_size_impl;
0032
0033 }
0034
0035 template<typename T>
0036 std::streamsize optimal_buffer_size(const T& t)
0037 {
0038 typedef detail::optimal_buffer_size_impl<T> impl;
0039 return impl::optimal_buffer_size(detail::unwrap(t));
0040 }
0041
0042 namespace detail {
0043
0044
0045
0046 template<typename T>
0047 struct optimal_buffer_size_impl
0048 : mpl::if_<
0049 is_custom<T>,
0050 operations<T>,
0051 optimal_buffer_size_impl<
0052 BOOST_DEDUCED_TYPENAME
0053 dispatch<
0054 T, optimally_buffered_tag, device_tag, filter_tag
0055 >::type
0056 >
0057 >::type
0058 { };
0059
0060 template<>
0061 struct optimal_buffer_size_impl<optimally_buffered_tag> {
0062 template<typename T>
0063 static std::streamsize optimal_buffer_size(const T& t)
0064 { return t.optimal_buffer_size(); }
0065 };
0066
0067 template<>
0068 struct optimal_buffer_size_impl<device_tag> {
0069 template<typename T>
0070 static std::streamsize optimal_buffer_size(const T&)
0071 { return default_device_buffer_size; }
0072 };
0073
0074 template<>
0075 struct optimal_buffer_size_impl<filter_tag> {
0076 template<typename T>
0077 static std::streamsize optimal_buffer_size(const T&)
0078 { return default_filter_buffer_size; }
0079 };
0080
0081 }
0082
0083 } }
0084
0085 #include <boost/iostreams/detail/config/enable_warnings.hpp>
0086
0087 #endif