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.) 4 5 // See http://www.boost.org/libs/iostreams for documentation. 6 7 #ifndef BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED 8 #define BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED 9 10 #include <boost/iostreams/detail/broken_overload_resolution/forward.hpp> 11 12 namespace boost { namespace iostreams { 13 14 template< typename Device, 15 typename Tr = 16 BOOST_IOSTREAMS_CHAR_TRAITS( 17 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type 18 ), 19 typename Alloc = 20 std::allocator< 21 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type 22 > > 23 struct stream : detail::stream_base<Device, Tr, Alloc> { 24 public: 25 typedef typename char_type_of<Device>::type char_type; 26 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) 27 private: 28 typedef typename 29 detail::stream_traits< 30 Device, Tr 31 >::type stream_type; 32 typedef Device policy_type; 33 public: streamboost::iostreams::stream34 stream() { } 35 template<typename U0> streamboost::iostreams::stream36 stream(const U0& u0) 37 { 38 open_impl(detail::forward<Device, U0>(), u0); 39 } 40 template<typename U0, typename U1> streamboost::iostreams::stream41 stream(const U0& u0, const U1& u1) 42 { 43 open_impl(detail::forward<Device, U0>(), u0, u1); 44 } 45 template<typename U0, typename U1, typename U2> streamboost::iostreams::stream46 stream(const U0& u0, const U1& u1, const U2& u2) 47 { 48 open_impl(detail::forward<Device, U0>(), u0, u1, u2); 49 } 50 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------// 51 template<typename U0> streamboost::iostreams::stream52 stream(U0& u0) 53 { 54 open_impl(detail::forward<Device, U0>(), u0); 55 } 56 template<typename U0, typename U1> streamboost::iostreams::stream57 stream(U0& u0, const U1& u1) 58 { 59 open_impl(detail::forward<Device, U0>(), u0, u1); 60 } 61 template<typename U0, typename U1, typename U2> streamboost::iostreams::stream62 stream(U0& u0, const U1& u1, const U2& u2) 63 { 64 open_impl(detail::forward<Device, U0>(), u0, u1, u2); 65 } 66 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------// 67 template<typename U0> openboost::iostreams::stream68 void open(const U0& u0) 69 { 70 open_impl(detail::forward<Device, U0>(), u0); 71 } 72 template<typename U0, typename U1> openboost::iostreams::stream73 void open(const U0& u0, const U1& u1) 74 { 75 open_impl(detail::forward<Device, U0>(), u0, u1); 76 } 77 template<typename U0, typename U1, typename U2> openboost::iostreams::stream78 void open(const U0& u0, const U1& u1, const U2& u2) 79 { 80 open_impl(detail::forward<Device, U0>(), u0, u1, u2); 81 } 82 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------// 83 template<typename U0> openboost::iostreams::stream84 void open(U0& u0) 85 { 86 open_impl(detail::forward<Device, U0>(), u0); 87 } 88 template<typename U0, typename U1> openboost::iostreams::stream89 void open(U0& u0, const U1& u1) 90 { 91 open_impl(detail::forward<Device, U0>(), u0, u1); 92 } 93 template<typename U0, typename U1, typename U2> openboost::iostreams::stream94 void open(U0& u0, const U1& u1, const U2& u2) 95 { 96 open_impl(detail::forward<Device, U0>(), u0, u1, u2); 97 } 98 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------// is_openboost::iostreams::stream99 bool is_open() const { return this->member.is_open(); } closeboost::iostreams::stream100 void close() { this->member.close(); } auto_closeboost::iostreams::stream101 bool auto_close() const { return this->member.auto_close(); } set_auto_closeboost::iostreams::stream102 void set_auto_close(bool close) { this->member.set_auto_close(close); } strict_syncboost::iostreams::stream103 bool strict_sync() { return this->member.strict_sync(); } operator *boost::iostreams::stream104 Device& operator*() { return *this->member; } operator ->boost::iostreams::stream105 Device* operator->() { return &*this->member; } 106 private: 107 template<typename U0> open_implboost::iostreams::stream108 void open_impl(mpl::false_, const U0& u0) 109 { 110 this->clear(); 111 this->member.open(u0); 112 } 113 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------// 114 template<typename U0> open_implboost::iostreams::stream115 void open_impl(mpl::false_, U0& u0) 116 { 117 this->clear(); 118 this->member.open(detail::wrap(u0)); 119 } 120 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------// 121 template<typename U0> open_implboost::iostreams::stream122 void open_impl(mpl::true_, const U0& u0) 123 { 124 this->clear(); 125 this->member.open(Device(const_cast<U0&>(u0))); 126 } 127 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------// 128 template<typename U0> open_implboost::iostreams::stream129 void open_impl(mpl::true_, U0& u0) 130 { 131 this->clear(); 132 this->member.open(Device(u0)); 133 } 134 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------// 135 template<typename U0, typename U1> open_implboost::iostreams::stream136 void open_impl(mpl::false_, const U0& u0, const U1& u1) 137 { 138 this->clear(); 139 this->member.open(u0, u1); 140 } 141 template<typename U0, typename U1> open_implboost::iostreams::stream142 void open_impl(mpl::true_, const U0& u0, const U1& u1) 143 { 144 this->clear(); 145 this->member.open(Device(const_cast<U0&>(u0), u1)); 146 } 147 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------// 148 template<typename U0, typename U1> open_implboost::iostreams::stream149 void open_impl(mpl::true_, U0& u0, const U1& u1) 150 { 151 this->clear(); 152 this->member.open(Device(u0, u1)); 153 } 154 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------// 155 template<typename U0, typename U1, typename U2> open_implboost::iostreams::stream156 void open_impl(mpl::false_, const U0& u0, const U1& u1, const U2& u2) 157 { 158 this->clear(); 159 this->member.open(u0, u1, u2); 160 } 161 template<typename U0, typename U1, typename U2> open_implboost::iostreams::stream162 void open_impl(mpl::true_, const U0& u0, const U1& u1, const U2& u2) 163 { 164 this->clear(); 165 this->member.open(Device(const_cast<U0&>(u0), u1, u2)); 166 } 167 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------// 168 template<typename U0, typename U1, typename U2> open_implboost::iostreams::stream169 void open_impl(mpl::true_, U0& u0, const U1& u1, const U2& u2) 170 { 171 this->clear(); 172 this->member.open(Device(u0, u1, u2)); 173 } 174 #endif 175 }; 176 177 } } // End namespaces iostreams, boost. 178 179 #endif BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED 180