Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-08-09 00:31:33


> To be honest, I don't use simple types with shared_ptr. I usually don't
> have a need.

Simple types like typenames, POD, classes not having virtual destructors or
could be simply user-defined with a new trait for advanced users.

> But there are two dereferences for every comparison in a sort, so even
> though a swap takes three copies, you don't necessarily swap on every
> comparison. It seems possible that there is no appreciable difference
> in a large number of cases.

- the indexing followed by an addition is negligeable because the pointer
usage already slows down member accesses;
- sort() may not have been the best example but creating, copying and
destroying a container of pointers + number of pointed object allocations
are the ones that will determine of your program is slow or not;
- length of the containers will always be half size also; you've just
*doubled* your free memory;
- benchmarking them will simply constitute the best proof.

- sizeof(struct { char b[sizeof(int)]; char c; }) is != from sizeof(struct
{ int i; char c; }). Fascinating.
- There is nothing defined related to alignments in the standards I
supposed?

Philippe A. Bouchard


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