fix doc example typo
[boost.git] / boost / iostreams / detail / broken_overload_resolution / stream.hpp
blob834f996f40e919a82cd18e5be66e1c5c9c788965
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_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
11 #include <boost/iostreams/detail/broken_overload_resolution/forward.hpp>
13 namespace boost { namespace iostreams {
15 template< typename Device,
16 typename Tr =
17 BOOST_IOSTREAMS_CHAR_TRAITS(
18 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
20 typename Alloc =
21 std::allocator<
22 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
23 > >
24 struct stream : detail::stream_base<Device, Tr, Alloc> {
25 public:
26 typedef typename char_type_of<Device>::type char_type;
27 struct category
28 : mode_of<Device>::type,
29 closable_tag,
30 detail::stream_traits<Device, Tr>::stream_tag
31 { };
32 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
33 private:
34 typedef typename
35 detail::stream_traits<
36 Device, Tr
37 >::stream_type stream_type;
38 public:
39 stream() { }
40 template<typename U0>
41 stream(const U0& u0)
43 open_impl(detail::forward<Device, U0>(), u0);
45 template<typename U0, typename U1>
46 stream(const U0& u0, const U1& u1)
48 open_impl(detail::forward<Device, U0>(), u0, u1);
50 template<typename U0, typename U1, typename U2>
51 stream(const U0& u0, const U1& u1, const U2& u2)
53 open_impl(detail::forward<Device, U0>(), u0, u1, u2);
55 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
56 template<typename U0>
57 stream(U0& u0)
59 open_impl(detail::forward<Device, U0>(), u0);
61 template<typename U0, typename U1>
62 stream(U0& u0, const U1& u1)
64 open_impl(detail::forward<Device, U0>(), u0, u1);
66 template<typename U0, typename U1, typename U2>
67 stream(U0& u0, const U1& u1, const U2& u2)
69 open_impl(detail::forward<Device, U0>(), u0, u1, u2);
71 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
72 template<typename U0>
73 void open(const U0& u0)
75 open_impl(detail::forward<Device, U0>(), u0);
77 template<typename U0, typename U1>
78 void open(const U0& u0, const U1& u1)
80 open_impl(detail::forward<Device, U0>(), u0, u1);
82 template<typename U0, typename U1, typename U2>
83 void open(const U0& u0, const U1& u1, const U2& u2)
85 open_impl(detail::forward<Device, U0>(), u0, u1, u2);
87 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
88 template<typename U0>
89 void open(U0& u0)
91 open_impl(detail::forward<Device, U0>(), u0);
93 template<typename U0, typename U1>
94 void open(U0& u0, const U1& u1)
96 open_impl(detail::forward<Device, U0>(), u0, u1);
98 template<typename U0, typename U1, typename U2>
99 void open(U0& u0, const U1& u1, const U2& u2)
101 open_impl(detail::forward<Device, U0>(), u0, u1, u2);
103 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
104 bool is_open() const { return this->member.is_open(); }
105 void close() { this->member.close(); }
106 bool auto_close() const { return this->member.auto_close(); }
107 void set_auto_close(bool close) { this->member.set_auto_close(close); }
108 bool strict_sync() { return this->member.strict_sync(); }
109 Device& operator*() { return *this->member; }
110 Device* operator->() { return &*this->member; }
111 private:
112 template<typename U0>
113 void open_impl(mpl::false_, const U0& u0)
115 this->clear();
116 this->member.open(u0);
118 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
119 template<typename U0>
120 void open_impl(mpl::false_, U0& u0)
122 this->clear();
123 this->member.open(detail::wrap(u0));
125 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
126 template<typename U0>
127 void open_impl(mpl::true_, const U0& u0)
129 this->clear();
130 this->member.open(Device(const_cast<U0&>(u0)));
132 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
133 template<typename U0>
134 void open_impl(mpl::true_, U0& u0)
136 this->clear();
137 this->member.open(Device(u0));
139 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
140 template<typename U0, typename U1>
141 void open_impl(mpl::false_, const U0& u0, const U1& u1)
143 this->clear();
144 this->member.open(u0, u1);
146 template<typename U0, typename U1>
147 void open_impl(mpl::true_, const U0& u0, const U1& u1)
149 this->clear();
150 this->member.open(Device(const_cast<U0&>(u0), u1));
152 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
153 template<typename U0, typename U1>
154 void open_impl(mpl::true_, U0& u0, const U1& u1)
156 this->clear();
157 this->member.open(Device(u0, u1));
159 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
160 template<typename U0, typename U1, typename U2>
161 void open_impl(mpl::false_, const U0& u0, const U1& u1, const U2& u2)
163 this->clear();
164 this->member.open(u0, u1, u2);
166 template<typename U0, typename U1, typename U2>
167 void open_impl(mpl::true_, const U0& u0, const U1& u1, const U2& u2)
169 this->clear();
170 this->member.open(Device(const_cast<U0&>(u0), u1, u2));
172 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
173 template<typename U0, typename U1, typename U2>
174 void open_impl(mpl::true_, U0& u0, const U1& u1, const U2& u2)
176 this->clear();
177 this->member.open(Device(u0, u1, u2));
179 #endif
182 } } // End namespaces iostreams, boost.
184 #endif BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED