$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Mattias Flodin (flodin_at_[hidden])
Date: 2001-11-13 15:38:18
On Tue, 13 Nov 2001, Mattias Flodin wrote:
> As for the trick in the constructor, it is there to allow constructs such
> as:
>
> class B : public A, public singleton<A> { /* ... */ };
>
> In this case, the 'this' pointer that singleton's ctor receives cannot be
> directly reinterpreted as a B pointer. The code essentially casts the
> number 1 from being a singleton pointer into being a A pointer, in order
> to determine the offset of A in relation to its aggregated singleton.
> Casting 0 does not work because such a cast is guaranteed never to modify
> the pointer, thus I must use 1 for casting and then subtract 1.
My apologies - I have confused A and B here. All references to 'A' in the
text should be 'B'.
-- Mattias Flodin <flodin_at_[hidden]> "A good thing about C++ is that only Room D418 friends can access your private parts" Department of Computing Science Umeå University S-901 87 Umeå, Sweden Note: Any opinions expressed in this mail are personal, and do not necessarily reflect an official standpoint of Umeå University.