sl@0: // Copyright (C) 2002 Brad King (brad.king@kitware.com) sl@0: // Douglas Gregor (gregod@cs.rpi.edu) sl@0: // Peter Dimov sl@0: // sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: // For more information, see http://www.boost.org sl@0: sl@0: #ifndef BOOST_UTILITY_ADDRESSOF_HPP sl@0: # define BOOST_UTILITY_ADDRESSOF_HPP sl@0: sl@0: # include sl@0: # include sl@0: sl@0: namespace boost { sl@0: sl@0: // Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov) sl@0: sl@0: // VC7 strips const from nested classes unless we add indirection here sl@0: # if BOOST_WORKAROUND(BOOST_MSVC, == 1300) sl@0: sl@0: template struct _addp sl@0: { sl@0: typedef T * type; sl@0: }; sl@0: sl@0: template typename _addp::type sl@0: sl@0: # else sl@0: template T* sl@0: # endif sl@0: addressof(T& v) sl@0: { sl@0: return reinterpret_cast( sl@0: &const_cast(reinterpret_cast(v))); sl@0: } sl@0: sl@0: // Borland doesn't like casting an array reference to a char reference sl@0: // but these overloads work around the problem. sl@0: # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) sl@0: template sl@0: T (*addressof(T (&t)[N]))[N] sl@0: { sl@0: return reinterpret_cast(&t); sl@0: } sl@0: sl@0: template sl@0: const T (*addressof(const T (&t)[N]))[N] sl@0: { sl@0: return reinterpret_cast(&t); sl@0: } sl@0: # endif sl@0: sl@0: } sl@0: sl@0: #endif // BOOST_UTILITY_ADDRESSOF_HPP