]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/utility.hpp
update from boost cvs
[lyx.git] / boost / boost / utility.hpp
index 7d3503aa827016c85a1cb7c8c330530f65595899..fa99b9a14818c2da81ec116992415c36d73bf657 100644 (file)
@@ -11,6 +11,9 @@
 //  Classes appear in alphabetical order
 
 //  Revision History
+//  21 May 01  checked_delete() and checked_array_delete() added (Beman Dawes,
+//             suggested by Dave Abrahams, generalizing idea from Vladimir Prus)
+//  21 May 01  made next() and prior() inline (Beman Dawes)  
 //  26 Jan 00  protected noncopyable destructor added (Miki Jovanovic)
 //  10 Dec 99  next() and prior() templates added (Dave Abrahams)
 //  30 Aug 99  moved cast templates to cast.hpp (Beman Dawes)
 #ifndef BOOST_UTILITY_HPP
 #define BOOST_UTILITY_HPP
 
-#include <boost/config.hpp>
-#include <cstddef>            // for size_t
-#include <utility>            // for std::pair
+#include <boost/config.hpp>        // broken compiler workarounds 
+#include <boost/static_assert.hpp> 
+#include <cstddef>                 // for size_t
+#include <utility>                 // for std::pair
 
-// LGB
-//namespace boost
-//{
+namespace boost
+{
+//  checked_delete() and checked_array_delete()  -----------------------------//
+
+    // verify that types are complete for increased safety
+
+    template< typename T >
+    inline void checked_delete(T * x)
+    {
+        BOOST_STATIC_ASSERT( sizeof(T) != 0 ); // assert type complete at point
+                                               // of instantiation
+        delete x;
+    }
+
+    template< typename T >
+    inline void checked_array_delete(T  * x)
+    {
+        BOOST_STATIC_ASSERT( sizeof(T) != 0 ); // assert type complete at point
+                                               // of instantiation
+        delete [] x;
+    }
 
 //  next() and prior() template functions  -----------------------------------//
 
     //  Contributed by Dave Abrahams
 
     template <class T>
-    T next(T x) { return ++x; }
+    inline T next(T x) { return ++x; }
 
     template <class T>
-    T prior(T x) { return --x; }
+    inline T prior(T x) { return --x; }
 
 
 //  class noncopyable  -------------------------------------------------------//
         const noncopyable& operator=( const noncopyable& );
     }; // noncopyable
 
-//  class tied  -------------------------------------------------------//
-
-    // A helper for conveniently assigning the two values from a pair
-    // into separate variables. The idea for this comes from Jaakko J\84rvi's
-    // Binder/Lambda Library.
 
-    // Constributed by Jeremy Siek
-
-    template <class A, class B>
-    class tied {
-    public:
-      inline tied(A& a, B& b) : _a(a), _b(b) { }
-      template <class U, class V>
-      inline tied& operator=(const std::pair<U,V>& p) {
-        _a = p.first;
-        _b = p.second;
-        return *this;
-      }
-    protected:
-      A& _a;
-      B& _b;
-    };
-
-    template <class A, class B>
-    inline tied<A,B> tie(A& a, B& b) { return tied<A,B>(a, b); }
-
-// LGB
-//} // namespace boost
+} // namespace boost
 
 #endif  // BOOST_UTILITY_HPP
 
-
-
-