Subject: Re: [boost] [interprocess] [bimap] Using raw pointers
From: Matias Capeletto (matias.capeletto_at_[hidden])
Date: 2013-01-27 13:00:29
On Sun, Jan 27, 2013 at 9:39 AM, Ion Gaztañaga <igaztanaga_at_[hidden]> wrote:
> 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:
This. It is exactly what I was looking for yesterday... any chance to
make this more visible? It is a very handy tool.
> 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.
Awesome. This is what I wanted to do, but I failed because the basic
piece in the puzzle was missing. Thanks a lot, I didn't actually
expected you to directly give it to me :)
I will do the changes then so Bimap can be used with Interprocess allocators.