| 
									
										
										
										
											2002-04-10 03:31:18 +00:00
										 |  |  | // Copyright (C) 2002 Brad King (brad.king@kitware.com) 
 | 
					
						
							| 
									
										
										
										
											2004-07-25 02:29:29 +00:00
										 |  |  | //                    Douglas Gregor (gregod@cs.rpi.edu)
 | 
					
						
							| 
									
										
										
										
											2002-04-13 13:19:57 +00:00
										 |  |  | //                    Peter Dimov
 | 
					
						
							| 
									
										
										
										
											2002-04-10 03:31:18 +00:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2004-07-27 03:43:34 +00:00
										 |  |  | // 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)
 | 
					
						
							| 
									
										
										
										
											2002-04-10 03:31:18 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // For more information, see http://www.boost.org
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef BOOST_UTILITY_ADDRESSOF_HPP
 | 
					
						
							| 
									
										
										
										
											2003-01-08 17:21:10 +00:00
										 |  |  | # define BOOST_UTILITY_ADDRESSOF_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # include <boost/config.hpp>
 | 
					
						
							|  |  |  | # include <boost/detail/workaround.hpp>
 | 
					
						
							| 
									
										
										
										
											2002-04-10 03:31:18 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace boost { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-13 13:19:57 +00:00
										 |  |  | // Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-01-08 17:21:10 +00:00
										 |  |  | // VC7 strips const from nested classes unless we add indirection here
 | 
					
						
							|  |  |  | # if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
 | 
					
						
							| 
									
										
										
										
											2005-03-16 22:02:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | template<class T> struct _addp | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     typedef T * type; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  | template <typename T> typename _addp<T>::type | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-01-08 17:21:10 +00:00
										 |  |  | # else
 | 
					
						
							|  |  |  | template <typename T> T* | 
					
						
							|  |  |  | # endif
 | 
					
						
							|  |  |  | addressof(T& v) | 
					
						
							| 
									
										
										
										
											2002-04-10 03:31:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2002-04-10 04:00:22 +00:00
										 |  |  |   return reinterpret_cast<T*>( | 
					
						
							| 
									
										
										
										
											2002-04-13 13:19:57 +00:00
										 |  |  |        &const_cast<char&>(reinterpret_cast<const volatile char &>(v))); | 
					
						
							| 
									
										
										
										
											2002-04-10 03:31:18 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-14 23:03:42 +00:00
										 |  |  | // 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<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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-10 03:31:18 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // BOOST_UTILITY_ADDRESSOF_HPP
 |