--- close.hpp.orig 2007-05-27 09:58:09.000000000 -0700 +++ close.hpp 2007-05-27 10:00:21.000000000 -0700 @@ -106,8 +106,12 @@ typedef typename category_of::type category; const bool in = is_convertible::value && !is_convertible::value; - if (in == ((which & BOOST_IOS::in) != 0)) + const bool out = is_convertible::value && + !is_convertible::value; + if ((in && ((which & BOOST_IOS::in) != 0)) || + (out && ((which & BOOST_IOS::out) != 0))) { t.close(); + } } template static void close(T& t, Sink& snk, BOOST_IOS::openmode which) @@ -115,7 +119,10 @@ typedef typename category_of::type category; const bool in = is_convertible::value && !is_convertible::value; - if (in == ((which & BOOST_IOS::in) != 0)) { + const bool out = is_convertible::value && + !is_convertible::value; + if ((in && ((which & BOOST_IOS::in) != 0)) || + (out && ((which & BOOST_IOS::out) != 0))) { non_blocking_adapter nb(snk); t.close(nb); }