diff --git a/include/boost/intrusive/detail/parent_from_member.hpp b/include/boost/intrusive/detail/parent_from_member.hpp index c566e77..c3becf1 100644 --- a/include/boost/intrusive/detail/parent_from_member.hpp +++ b/include/boost/intrusive/detail/parent_from_member.hpp @@ -16,6 +16,11 @@ #include #include +#if defined(BOOST_MSVC) || (defined (BOOST_WINDOWS) && defined(BOOST_INTEL)) +#define BOOST_INTRUSIVE_OFFSET_FROM_PTR2MEMBER_MSVC_COMPLIANT +#include +#endif + namespace boost { namespace intrusive { namespace detail { @@ -23,11 +28,10 @@ namespace detail { template inline std::size_t offset_from_pointer_to_member(const Member Parent::* ptr_to_member) { - //BOOST_STATIC_ASSERT(( sizeof(std::ptrdiff_t) == sizeof(ptr_to_member) )); //The implementation of a pointer to member is compiler dependent. - #if defined(BOOST_MSVC) || (defined (BOOST_WINDOWS) && defined(BOOST_INTEL)) + #if defined(BOOST_INTRUSIVE_OFFSET_FROM_PTR2MEMBER_MSVC_COMPLIANT) //This works with gcc, msvc, ac++, ibmcpp - return *(const std::ptrdiff_t*)(void*)&ptr_to_member; + return *(const boost::int32_t*)(void*)&ptr_to_member; #elif defined(__GNUC__) || defined(__HP_aCC) || defined(BOOST_INTEL) || defined (__IBMCPP__) || defined (__DECCXX) const Parent * const parent = 0; const char *const member = reinterpret_cast(&(parent->*ptr_to_member)); @@ -56,6 +60,10 @@ inline const Parent *parent_from_member(const Member *member, const Member Paren } //namespace intrusive { } //namespace boost { +#ifdef BOOST_INTRUSIVE_OFFSET_FROM_PTR2MEMBER_MSVC_COMPLIANT +#undef BOOST_INTRUSIVE_OFFSET_FROM_PTR2MEMBER_MSVC_COMPLIANT +#endif + #include #endif //#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP