aboutsummaryrefslogtreecommitdiff
path: root/cutl/details/boost/utility
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-06-28 17:17:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-06-28 17:17:23 +0200
commitb51965dddbed68f23c5e8c169c23c794313ce5f6 (patch)
tree37bbdf4e5b1cdd34ea0694a5abd1483d1de2b3af /cutl/details/boost/utility
parent5f06e7e30e4f511ce2fb27c5feefa6aeb6f00841 (diff)
Add boost subset as an implementation detail
Diffstat (limited to 'cutl/details/boost/utility')
-rw-r--r--cutl/details/boost/utility/addressof.hpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/cutl/details/boost/utility/addressof.hpp b/cutl/details/boost/utility/addressof.hpp
new file mode 100644
index 0000000..56ed1bc
--- /dev/null
+++ b/cutl/details/boost/utility/addressof.hpp
@@ -0,0 +1,102 @@
+// Copyright (C) 2002 Brad King (brad.king@kitware.com)
+// Douglas Gregor (gregod@cs.rpi.edu)
+//
+// 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
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#ifndef BOOST_UTILITY_ADDRESSOF_HPP
+# define BOOST_UTILITY_ADDRESSOF_HPP
+
+# include <cutl/details/boost/config.hpp>
+# include <cutl/details/boost/detail/workaround.hpp>
+
+namespace cutl_details_boost
+{
+
+namespace detail
+{
+
+template<class T> struct addr_impl_ref
+{
+ T & v_;
+
+ inline addr_impl_ref( T & v ): v_( v ) {}
+ inline operator T& () const { return v_; }
+
+private:
+ addr_impl_ref & operator=(const addr_impl_ref &);
+};
+
+template<class T> struct addressof_impl
+{
+ 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 )
+{
+#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) )
+
+ return cutl_details_boost::detail::addressof_impl<T>::f( v, 0 );
+
+#else
+
+ return cutl_details_boost::detail::addressof_impl<T>::f( cutl_details_boost::detail::addr_impl_ref<T>( v ), 0 );
+
+#endif
+}
+
+#if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) )
+
+namespace detail
+{
+
+template<class T> struct addressof_addp
+{
+ typedef T * type;
+};
+
+} // namespace detail
+
+template< class T, std::size_t N >
+typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
+{
+ return &t;
+}
+
+#endif
+
+// Borland doesn't like casting an array reference to a char reference
+// but these overloads work around the problem.
+#if defined( __BORLANDC__ ) && 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 cutl_details_boost
+
+#endif // BOOST_UTILITY_ADDRESSOF_HPP