mirror of
https://github.com/boostorg/utility.git
synced 2025-05-08 18:34:02 +00:00
work-around for Borland addressof(array) bug and associated tests
[SVN r27656]
This commit is contained in:
parent
3ab4d38931
commit
ae19cd6236
@ -36,6 +36,14 @@ int test_main(int, char*[])
|
||||
|
||||
const volatile nonaddressable& cvx = *px;
|
||||
BOOST_CHECK(boost::addressof(cvx) == static_cast<const volatile nonaddressable*>(px));
|
||||
|
||||
|
||||
int nrg[3] = {1,2,3};
|
||||
int (*pnrg)[3] = &nrg;
|
||||
BOOST_CHECK(boost::addressof(nrg) == pnrg);
|
||||
|
||||
int const cnrg[3] = {1,2,3};
|
||||
int const (*pcnrg)[3] = &cnrg;
|
||||
BOOST_CHECK(boost::addressof(cnrg) == pcnrg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,6 +33,22 @@ addressof(T& v)
|
||||
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_UTILITY_ADDRESSOF_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user