]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/utility/addressof.hpp
update boost to version 1.36
[lyx.git] / boost / boost / utility / addressof.hpp
index 603ea60e379f780252efbcf56d1899943d1545ec..8e0a586880ec53de60565f422ef6d4677aa4db2d 100644 (file)
@@ -1,6 +1,7 @@
 // Copyright (C) 2002 Brad King (brad.king@kitware.com) 
 //                    Douglas Gregor (gregod@cs.rpi.edu)
-//                    Peter Dimov
+//
+// Copyright (C) 2002, 2008 Peter Dimov
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
 
 # include <boost/config.hpp>
 # include <boost/detail/workaround.hpp>
-# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
-#  include <boost/type_traits/add_pointer.hpp>
-# endif
 
-namespace boost {
+namespace boost
+{
 
-// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
+namespace detail
+{
 
-// VC7 strips const from nested classes unless we add indirection here
-# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
-template <typename T> typename add_pointer<T>::type
-# else
-template <typename T> T*
-# endif
-addressof(T& v)
+template<class T> struct addressof_impl
 {
-  return reinterpret_cast<T*>(
-       &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
+    static inline T * f( T & v, long )
+    {
+        return reinterpret_cast<T*>(
+            &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
+    }
+
+    static inline T * f( T * v, int )
+    {
+        return v;
+    }
+};
+
+} // namespace detail
+
+template<class T> T * addressof( T & v )
+{
+    return boost::detail::addressof_impl<T>::f( v, 0 );
 }
 
+// Borland doesn't like casting an array reference to a char reference
+// but these overloads work around the problem.
+# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+template<typename T,std::size_t N>
+T (*addressof(T (&t)[N]))[N]
+{
+   return reinterpret_cast<T(*)[N]>(&t);
 }
 
+template<typename T,std::size_t N>
+const T (*addressof(const T (&t)[N]))[N]
+{
+   return reinterpret_cast<const T(*)[N]>(&t);
+}
+# endif
+
+} // namespace boost
+
 #endif // BOOST_UTILITY_ADDRESSOF_HPP