Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:44:33

0001 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
0002 // (C) Copyright 2003-2007 Jonathan Turkanis
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
0005 
0006 // See http://www.boost.org/libs/iostreams for documentation.
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 // Must come last.
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 } // End namespace detail.
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 //------------------Definition of optimal_buffer_size_impl--------------------//
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 } // End namespace detail.
0082 
0083 } } // End namespaces iostreams, boost.
0084 
0085 #include <boost/iostreams/detail/config/enable_warnings.hpp>
0086 
0087 #endif // #ifndef BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED