addressof.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2002 Brad King (brad.king@kitware.com) 
00002 //                    Douglas Gregor (gregod@cs.rpi.edu)
00003 //                    Peter Dimov
00004 //
00005 // Distributed under the Boost Software License, Version 1.0. (See
00006 // accompanying file LICENSE_1_0.txt or copy at
00007 // http://www.boost.org/LICENSE_1_0.txt)
00008 
00009 // For more information, see http://www.boost.org
00010 
00011 #ifndef BOOST_UTILITY_ADDRESSOF_HPP
00012 # define BOOST_UTILITY_ADDRESSOF_HPP
00013 
00014 # include <sysc/packages/boost/config.hpp>
00015 # include <sysc/packages/boost/detail/workaround.hpp>
00016 
00017 namespace boost {
00018 
00019 // Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
00020 
00021 // VC7 strips const from nested classes unless we add indirection here
00022 # if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
00023 
00024 template<class T> struct _addp
00025 {
00026     typedef T * type;
00027 };
00028     
00029 template <typename T> typename _addp<T>::type
00030 
00031 # else
00032 template <typename T> T*
00033 # endif
00034 addressof(T& v)
00035 {
00036   return reinterpret_cast<T*>(
00037        &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
00038 }
00039 
00040 // Borland doesn't like casting an array reference to a char reference
00041 // but these overloads work around the problem.
00042 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
00043 template<typename T,std::size_t N>
00044 T (*addressof(T (&t)[N]))[N]
00045 {
00046    return reinterpret_cast<T(*)[N]>(&t);
00047 }
00048 
00049 template<typename T,std::size_t N>
00050 const T (*addressof(const T (&t)[N]))[N]
00051 {
00052    return reinterpret_cast<const T(*)[N]>(&t);
00053 }
00054 # endif
00055 
00056 }
00057 
00058 #endif // BOOST_UTILITY_ADDRESSOF_HPP

Generated on Wed Jan 21 15:32:10 2009 for SystemC by  doxygen 1.5.5