Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2007-12-18 17:55:20


Author: turkanis
Date: 2007-12-18 17:55:20 EST (Tue, 18 Dec 2007)
New Revision: 42154
URL: http://svn.boost.org/trac/boost/changeset/42154

Log:
allow deprecated calls to close(t, [s,] in | out) unless BOOST_IOSTREAMS_STRICT is defined
Text files modified:
   branches/iostreams_dev/boost/iostreams/close.hpp | 110 +++++++++++++++++++++------------------
   branches/iostreams_dev/boost/iostreams/detail/vc6/close.hpp | 3 +
   2 files changed, 63 insertions(+), 50 deletions(-)

Modified: branches/iostreams_dev/boost/iostreams/close.hpp
==============================================================================
--- branches/iostreams_dev/boost/iostreams/close.hpp (original)
+++ branches/iostreams_dev/boost/iostreams/close.hpp 2007-12-18 17:55:20 EST (Tue, 18 Dec 2007)
@@ -30,6 +30,51 @@
 // Must come last.
 #include <boost/iostreams/detail/config/disable_warnings.hpp>
 
+namespace boost { namespace iostreams {
+
+template<typename T>
+void close(T& t);
+
+template<typename T>
+void close(T& t, BOOST_IOS::openmode which);
+
+template<typename T, typename Sink>
+void close(T& t, Sink& snk, BOOST_IOS::openmode which);
+
+namespace detail {
+
+template<typename T>
+void close_all(T& t)
+{
+ try {
+ boost::iostreams::close(t, BOOST_IOS::in);
+ } catch (...) {
+ try {
+ boost::iostreams::close(t, BOOST_IOS::out);
+ } catch (...) { }
+ throw;
+ }
+ boost::iostreams::close(t, BOOST_IOS::out);
+}
+
+template<typename T, typename Sink>
+void close_all(T& t, Sink& snk)
+{
+ try {
+ boost::iostreams::close(t, snk, BOOST_IOS::in);
+ } catch (...) {
+ try {
+ boost::iostreams::close(t, snk, BOOST_IOS::out);
+ } catch (...) { }
+ throw;
+ }
+ boost::iostreams::close(t, snk, BOOST_IOS::out);
+}
+
+} // End namespaces detail.
+
+} } // End namespaces iostreams, boost.
+
 #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-----------------------------------//
 # include <boost/iostreams/detail/vc6/close.hpp>
 #else // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //--------------------------//
@@ -44,29 +89,33 @@
 } // End namespace detail.
 
 template<typename T>
-void close(T& t);
+void close(T& t) { detail::close_all(t); }
 
 template<typename T>
 void close(T& t, BOOST_IOS::openmode which)
 {
+#ifdef BOOST_IOSTREAMS_STRICT
     assert(which == BOOST_IOS::in || which == BOOST_IOS::out);
+#else
+ if (which == (BOOST_IOS::in | BOOST_IOS::out)) {
+ detail::close_all(t);
+ return;
+ }
+#endif
     detail::close_impl<T>::close(detail::unwrap(t), which);
 }
 
-//template<typename T, typename Sink>
-//void close( T& t, Sink& snk,
-// typename
-// boost::disable_if<
-// boost::is_convertible<Sink, BOOST_IOS::openmode>
-// >::type* = 0 )
-//{
-// detail::close_all(t, snk);
-//}
-
 template<typename T, typename Sink>
 void close(T& t, Sink& snk, BOOST_IOS::openmode which)
 {
+#ifdef BOOST_IOSTREAMS_STRICT
     assert(which == BOOST_IOS::in || which == BOOST_IOS::out);
+#else
+ if (which == (BOOST_IOS::in | BOOST_IOS::out)) {
+ detail::close_all(t, snk);
+ return;
+ }
+#endif
     detail::close_impl<T>::close(detail::unwrap(t), snk, which);
 }
 
@@ -163,45 +212,6 @@
 
 #endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-------------------------//
 
-namespace boost { namespace iostreams {
-
-namespace detail {
-
-template<typename T>
-void close_all(T& t)
-{
- try {
- boost::iostreams::close(t, BOOST_IOS::in);
- } catch (...) {
- try {
- boost::iostreams::close(t, BOOST_IOS::out);
- } catch (...) { }
- throw;
- }
- boost::iostreams::close(t, BOOST_IOS::out);
-}
-
-template<typename T, typename Sink>
-void close_all(T& t, Sink& snk)
-{
- try {
- boost::iostreams::close(t, snk, BOOST_IOS::in);
- } catch (...) {
- try {
- boost::iostreams::close(t, snk, BOOST_IOS::out);
- } catch (...) { }
- throw;
- }
- boost::iostreams::close(t, snk, BOOST_IOS::out);
-}
-
-} // End namespaces detail.
-
-template<typename T>
-void close(T& t) { detail::close_all(t); }
-
-} } // End iostreams, boost.
-
 #include <boost/iostreams/detail/config/enable_warnings.hpp>
 
 #endif // #ifndef BOOST_IOSTREAMS_CLOSE_HPP_INCLUDED

Modified: branches/iostreams_dev/boost/iostreams/detail/vc6/close.hpp
==============================================================================
--- branches/iostreams_dev/boost/iostreams/detail/vc6/close.hpp (original)
+++ branches/iostreams_dev/boost/iostreams/detail/vc6/close.hpp 2007-12-18 17:55:20 EST (Tue, 18 Dec 2007)
@@ -14,6 +14,9 @@
 } // End namespace detail.
 
 template<typename T>
+void close(T& t) { detail::close_all(t); }
+
+template<typename T>
 void close(T& t, BOOST_IOS::openmode which)
 {
     typedef typename detail::unwrapped_type<T>::type unwrapped;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk