Boost logo

Boost :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2007-10-19 10:30:10


Markus Schöpflin escribió:
> Hello,
>
> by now I have intrusive pass all regression tests locally. There is one
> modification left, which I'm not sure off, therefore I would like to ask
> for some advice before committing.
>
> All remaining failures are due to the implementation of
> offset_from_pointer_to_member():
>
> template<class Parent, class Member>
> inline std::size_t offset_from_pointer_to_member(
> const Member Parent::* ptr_to_member)
> {
> #if ... // 1
> return *(const std::ptrdiff_t*)(void*)&ptr_to_member;
> #elif ... // 2
> const Parent * const parent = 0;
> const char *const member =
> reinterpret_cast<const char*>(&(parent->*ptr_to_member));
> return std::size_t(member - reinterpret_cast<const char*>(parent));
> #else ... // 3
> return (*(const std::ptrdiff_t*)(void*)&ptr_to_member) - 1;
> #endif
> }
>
> Currently, variant #3 is chosen, which is obviously wrong. I tried both
> variant #1 and #2, and both seem to work for CXX. (All tests pass, no
> crashes.) So which variant should I choose?

Whatever you want. The first option was added because it was the only
one MSVC supports (otherwise, virtual base test crashes). If you don't
care, put it on the second case.

Regards,

Ion
>
> TIA, Markus
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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