Update contrib.
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_STREAM_BUFFER_HPP_INCLUDED
8 #define BOOST_IOSTREAMS_STREAM_BUFFER_HPP_INCLUDED
10 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
14 #include <memory> // allocator.
15 #include <boost/config.hpp> // BOOST_DEDUCED_TYPENAME.
16 #include <boost/iostreams/detail/char_traits.hpp>
17 #include <boost/iostreams/detail/config/overload_resolution.hpp>
18 #include <boost/iostreams/detail/forward.hpp>
19 #include <boost/iostreams/detail/ios.hpp> // failure, streamsize.
20 #include <boost/iostreams/detail/streambuf/direct_streambuf.hpp>
21 #include <boost/iostreams/detail/streambuf/indirect_streambuf.hpp>
22 #include <boost/iostreams/traits.hpp>
23 #include <boost/static_assert.hpp>
24 #include <boost/type_traits/is_convertible.hpp>
27 #include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
29 namespace boost { namespace iostreams { namespace detail {
31 template<typename T, typename Tr, typename Alloc, typename Mode>
32 struct stream_buffer_traits {
36 BOOST_DEDUCED_TYPENAME category_of<T>::type,
39 direct_streambuf<T, Tr>,
40 indirect_streambuf<T, Tr, Alloc, Mode>
44 } } } // End namespaces detail, iostreams, boost
46 #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
47 # include <boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp>
50 namespace boost { namespace iostreams {
54 BOOST_IOSTREAMS_CHAR_TRAITS(
55 BOOST_DEDUCED_TYPENAME char_type_of<T>::type
59 BOOST_DEDUCED_TYPENAME char_type_of<T>::type
61 typename Mode = BOOST_DEDUCED_TYPENAME mode_of<T>::type >
63 : public detail::stream_buffer_traits<T, Tr, Alloc, Mode>::type
68 BOOST_DEDUCED_TYPENAME iostreams::category_of<T>::type, Mode
72 detail::stream_buffer_traits<
75 typedef T policy_type;
77 typedef typename char_type_of<T>::type char_type;
78 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
84 if (this->is_open() && this->auto_close())
86 } catch (std::exception&) { }
88 BOOST_IOSTREAMS_FORWARD( stream_buffer, open_impl, T,
89 BOOST_IOSTREAMS_PUSH_PARAMS,
90 BOOST_IOSTREAMS_PUSH_ARGS )
91 T& operator*() { return *this->component(); }
92 T* operator->() { return this->component(); }
94 void open_impl(const T& t BOOST_IOSTREAMS_PUSH_PARAMS())
95 { // Used for forwarding.
97 BOOST_IOSTREAMS_FAILURE("already open");
98 base_type::open(t BOOST_IOSTREAMS_PUSH_ARGS());
102 } } // End namespaces iostreams, boost.
104 #endif // #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
106 #include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC.
108 #endif // #ifndef BOOST_IOSTREAMS_STREAM_BUFFER_HPP_INCLUDED