|
Boost : |
From: Greg Colvin (gcolvin_at_[hidden])
Date: 1999-11-19 12:01:48
From: scleary_at_[hidden]
> I have found a slightly different form to be useful in my programming. I
> originally used Nathan's code, but added typedef's for the template
> parameters, the capability of letting Member be a reference type, and a
> specialization for swap (if Member has specialized swap for efficiency, that
> specialization is lost in the original, even if Base is empty). Lastly, for
> convenience, I added three additional constructors. I chose to use the name
> "empty_member".
>
> I'm including the code I use below, and the docs that I made for it for my
> personal use. These docs may serve as a useful starting point; feel free to
> use the docs or code in any way you see fit.
>
> One thing I know aren't in my docs are requirements for Base and Member.
>
> -Steve
>
> P.S. All of the code changes mentioned above (in the first paragraph) I
> would recommend incorporating, except possibly the additional constructors.
> I have used each of them at least once.
Looks interesting, and certainly the additional typedefs are keeping with
out style. The T&, const T& trick is very clever, but I wonder if it is
actually needed with modern compilers. That is, given an inlined constructor
struct X { T t; X(T t):t(t){} };
is the compiler required to make a copy of the T parameter, or can it assign
the T argument directly to the T member? That is, in the statement
X x(t);
is the compiler allowed to copy t only once, or must it first push it on
the stack?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk