Boost logo

Boost :

Subject: Re: [boost] [interprocess] [bimap] Using raw pointers
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2013-01-27 03:39:57

El 27/01/2013 9:02, Matias Capeletto escribió:
> Any attempt to use the offset of the member to get to the bimap class
> seems to be forbidden by the standard.

Yes, i'ts undefined behaviour in theory but not in practice.
Boost.Intrusive has a useful function implemented for many compilers:

It's similar to a "downcast" but using members. Like "static_cast", it
does not work with virtual inheritance.

In your case the pointer to member value can be a compile-time constant
(so &Bimap::left can be passed as a template parameter). This constant
can be part of the type "left_map" or the compile-time pointer to member
could be obtained by left_map by a metafunction, call parent_from_member
passing "this" and the compile-time pointer to member value, obtaining
the pointer to Bimap. This way you can avoid storing any pointer to
Bimap into left_map.



Boost list run by bdawes at, gregod at, cpdaniel at, john at