]> git.lyx.org Git - lyx.git/blob - boost/boost/utility/addressof.hpp
Boost 1.31.0
[lyx.git] / boost / boost / utility / addressof.hpp
1 // Copyright (C) 2002 Brad King (brad.king@kitware.com) 
2 //                    Doug Gregor (gregod@cs.rpi.edu)
3 //                    Peter Dimov
4 //
5 // Permission to copy, use, sell and distribute this software is granted
6 // provided this copyright notice appears in all copies.
7 // Permission to modify the code and to distribute modified code is granted
8 // provided this copyright notice appears in all copies, and a notice
9 // that the code was modified is included with the copyright notice.
10 //
11 // This software is provided "as is" without express or implied warranty,
12 // and with no claim as to its suitability for any purpose.
13
14 // For more information, see http://www.boost.org
15
16 #ifndef BOOST_UTILITY_ADDRESSOF_HPP
17 # define BOOST_UTILITY_ADDRESSOF_HPP
18
19 # include <boost/config.hpp>
20 # include <boost/detail/workaround.hpp>
21 # if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
22 #  include <boost/type_traits/add_pointer.hpp>
23 # endif
24
25 namespace boost {
26
27 // Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
28
29 // VC7 strips const from nested classes unless we add indirection here
30 # if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
31 template <typename T> typename add_pointer<T>::type
32 # else
33 template <typename T> T*
34 # endif
35 addressof(T& v)
36 {
37   return reinterpret_cast<T*>(
38        &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
39 }
40
41 }
42
43 #endif // BOOST_UTILITY_ADDRESSOF_HPP