]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/intrusive_ptr.hpp
* src/MenuBackend.[Ch]: the specialMenu is now a real menu, not a
[lyx.git] / boost / boost / intrusive_ptr.hpp
index 3b988a8f5ab71172d141c5b7a3e0dad01687efd3..cd1ac11fae4d9e5b023b673bc832dfb736cb6830 100644 (file)
@@ -6,14 +6,15 @@
 //
 //  Copyright (c) 2001, 2002 Peter Dimov
 //
-//  Permission to copy, use, modify, sell and distribute this software
-//  is granted provided this copyright notice appears in all copies.
-//  This software is provided "as is" without express or implied
-//  warranty, and with no claim as to its suitability for any purpose.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 //
 //  See http://www.boost.org/libs/smart_ptr/intrusive_ptr.html for documentation.
 //
 
+#include <boost/config.hpp>
+
 #ifdef BOOST_MSVC  // moved here to work around VC++ compiler crash
 # pragma warning(push)
 # pragma warning(disable:4284) // odd return type for operator->
@@ -119,13 +120,32 @@ public:
         return p_;
     }
 
-    typedef T * (intrusive_ptr::*unspecified_bool_type) () const;
+#if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530)
+
+    operator bool () const
+    {
+        return p_ != 0;
+    }
+
+#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
+    typedef T * (this_type::*unspecified_bool_type)() const;
+    
+    operator unspecified_bool_type() const // never throws
+    {
+        return p_ == 0? 0: &this_type::get;
+    }
+
+#else 
+
+    typedef T * this_type::*unspecified_bool_type;
 
     operator unspecified_bool_type () const
     {
-        return p_ == 0? 0: &intrusive_ptr::get;
+        return p_ == 0? 0: &this_type::p_;
     }
 
+#endif
+
     // operator! is a Borland-specific workaround
     bool operator! () const
     {
@@ -154,22 +174,22 @@ template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, in
     return a.get() != b.get();
 }
 
-template<class T> inline bool operator==(intrusive_ptr<T> const & a, T * b)
+template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, U * b)
 {
     return a.get() == b;
 }
 
-template<class T> inline bool operator!=(intrusive_ptr<T> const & a, T * b)
+template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, U * b)
 {
     return a.get() != b;
 }
 
-template<class T> inline bool operator==(T * a, intrusive_ptr<T> const & b)
+template<class T, class U> inline bool operator==(T * a, intrusive_ptr<U> const & b)
 {
     return a == b.get();
 }
 
-template<class T> inline bool operator!=(T * a, intrusive_ptr<T> const & b)
+template<class T, class U> inline bool operator!=(T * a, intrusive_ptr<U> const & b)
 {
     return a != b.get();
 }
@@ -207,6 +227,11 @@ template<class T, class U> intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U>
     return static_cast<T *>(p.get());
 }
 
+template<class T, class U> intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & p)
+{
+    return const_cast<T *>(p.get());
+}
+
 template<class T, class U> intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & p)
 {
     return dynamic_cast<T *>(p.get());
@@ -224,7 +249,10 @@ template<class Y> std::ostream & operator<< (std::ostream & os, intrusive_ptr<Y>
 
 #else
 
-# if BOOST_WORKAROUND(BOOST_MSVC, <= 1200 && __SGI_STL_PORT)
+// in STLport's no-iostreams mode no iostream symbols can be used
+#ifndef _STLP_NO_IOSTREAMS
+
+# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300 && __SGI_STL_PORT)
 // MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL
 using std::basic_ostream;
 template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, intrusive_ptr<Y> const & p)
@@ -236,7 +264,9 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::
     return os;
 }
 
-#endif
+#endif // _STLP_NO_IOSTREAMS
+
+#endif // __GNUC__ < 3
 
 } // namespace boost