Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-03-14 13:26:21


Borland doesn't like boost::addressof when used with arrays. It won't
let you reinterpret_cast from an array reference to a char &. Russell
Hind was good enough to test the following patch for me and confirmed
that it works around the problem. (This is needed to get BOOST_FOREACH
to work with Borland.)

If no one objects, I'll apply the patch myself.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Index: addressof.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/utility/addressof.hpp,v
retrieving revision 1.7
diff -b -d -u -r1.7 addressof.hpp
--- addressof.hpp 27 Jul 2004 03:43:33 -0000 1.7
+++ addressof.hpp 14 Mar 2005 18:15:31 -0000
@@ -33,6 +33,22 @@
        &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
 }
 
+// Borland doesn't like casting an array reference to a char reference
+// but thes 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
+
 }
 
 #endif // BOOST_UTILITY_ADDRESSOF_HPP


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk