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_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED
11 #include <boost/iostreams/detail/broken_overload_resolution/forward.hpp>
12 #include <boost/throw_exception.hpp>
14 namespace boost { namespace iostreams {
18 BOOST_IOSTREAMS_CHAR_TRAITS(
19 BOOST_DEDUCED_TYPENAME char_type_of<T>::type
23 BOOST_DEDUCED_TYPENAME char_type_of<T>::type
25 typename Mode = BOOST_DEDUCED_TYPENAME mode_of<T>::type >
27 : public detail::stream_buffer_traits<T, Tr, Alloc, Mode>::type
32 BOOST_DEDUCED_TYPENAME iostreams::category_of<T>::type, Mode
36 detail::stream_buffer_traits<
40 typedef typename char_type_of<T>::type char_type;
46 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
51 if (this->is_open() && this->auto_close())
56 stream_buffer(const U0& u0)
58 open_impl(detail::forward<T, U0>(), u0);
60 template<typename U0, typename U1>
61 stream_buffer(const U0& u0, const U1& u1)
63 open_impl(detail::forward<T, U0>(), u0, u1);
65 template<typename U0, typename U1, typename U2>
66 stream_buffer(const U0& u0, const U1& u1, const U2& u2)
68 open_impl(detail::forward<T, U0>(), u0, u1, u2);
70 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
74 open_impl(detail::forward<T, U0>(), u0);
76 template<typename U0, typename U1>
77 stream_buffer(U0& u0, const U1& u1)
79 open_impl(detail::forward<T, U0>(), u0, u1);
81 template<typename U0, typename U1, typename U2>
82 stream_buffer(U0& u0, const U1& u1, const U2& u2)
84 open_impl(detail::forward<T, U0>(), u0, u1, u2);
86 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
88 void open(const U0& u0)
90 open_impl(detail::forward<T, U0>(), u0);
92 template<typename U0, typename U1>
93 void open(const U0& u0, const U1& u1)
95 open_impl(detail::forward<T, U0>(), u0, u1);
97 template<typename U0, typename U1, typename U2>
98 void open(const U0& u0, const U1& u1, const U2& u2)
100 open_impl(detail::forward<T, U0>(), u0, u1, u2);
102 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
103 template<typename U0>
106 open_impl(detail::forward<T, U0>(), u0);
108 template<typename U0, typename U1>
109 void open(U0& u0, const U1& u1)
111 open_impl(detail::forward<T, U0>(), u0, u1);
113 template<typename U0, typename U1, typename U2>
114 void open(U0& u0, const U1& u1, const U2& u2)
116 open_impl(detail::forward<T, U0>(), u0, u1, u2);
118 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
119 T& operator*() { return *this->component(); }
120 T* operator->() { return this->component(); }
122 template<typename U0>
123 void open_impl(mpl::false_, const U0& u0)
125 base_type::open(const_cast<U0&>(u0), -1, -1);
127 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
128 template<typename U0>
129 void open_impl(mpl::false_, U0& u0)
131 base_type::open(detail::wrap(u0), -1, -1);
133 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
134 template<typename U0>
135 void open_impl(mpl::true_, const U0& u0)
137 base_type::open(T(const_cast<U0&>(u0)), -1, -1);
139 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
140 template<typename U0>
141 void open_impl(mpl::true_, U0& u0)
143 base_type::open(T(u0), -1, -1);
145 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
146 template<typename U0, typename U1>
147 void open_impl(mpl::false_, const U0& u0, const U1& u1)
149 base_type::open(u0, u1, -1);
151 template<typename U0, typename U1>
152 void open_impl(mpl::true_, const U0& u0, const U1& u1)
154 base_type::open(T(const_cast<U0&>(u0), u1), -1, -1);
156 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
157 template<typename U0, typename U1>
158 void open_impl(mpl::true_, U0& u0, const U1& u1)
160 base_type::open(T(u0, u1), -1, -1);
162 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
163 template<typename U0, typename U1, typename U2>
164 void open_impl(mpl::false_, const U0& u0, const U1& u1, const U2& u2)
166 base_type::open(u0, u1, u2);
168 template<typename U0, typename U1, typename U2>
169 void open_impl(mpl::true_, const U0& u0, const U1& u1, const U2& u2)
171 base_type::open(T(const_cast<U0&>(u0), u1, u2), -1, -1);
173 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
174 template<typename U0, typename U1, typename U2>
175 void open_impl(mpl::true_, U0& u0, const U1& u1, const U2& u2)
177 base_type::open(T(u0, u1, u2), -1, -1);
179 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
183 boost::throw_exception(BOOST_IOSTREAMS_FAILURE("already open"));
187 } } // End namespaces iostreams, boost.
189 #endif // BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED