// 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 # include namespace boost { namespace detail { template struct addressof_impl { static inline T * f( T & v, long ) { return reinterpret_cast( &const_cast(reinterpret_cast(v))); } static inline T * f( T * v, int ) { return v; } }; } // namespace detail template T * addressof( T & v ) { return boost::detail::addressof_impl::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 T (*addressof(T (&t)[N]))[N] { return reinterpret_cast(&t); } template const T (*addressof(const T (&t)[N]))[N] { return reinterpret_cast(&t); } # endif } // namespace boost #endif // BOOST_UTILITY_ADDRESSOF_HPP