|
Boost : |
From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-08-02 15:31:06
I made a different version of ptr<> that handles polymorphic pointers.
The speed of the class is mainly depended on the number of distinct new U
allocations that are first encountered. Once they are encountered it is as
fast as (real pointer + constant) to dereference. Not to mention that
sizeof(ptr<T>) = sizeof(T *) thus copying large containers will be faster.
Memory is directly proportional to the number of combinaisons the program
may encounter between ptr<T> instanciations with the total number of new U
allocations associated with them.
Thus:
+ sizeof(ptr<T>) = sizeof(T *);
+ once different associations are made large containers can take advantage
of the memory and speed benefits (pool usage cannot do that);
- sizeof(new () T) = sizeof(T) + sizeof(int) * 2;
- speedof(* ptr<T>) = speedof(* T) + C.
Question:
- __type_traits doesn't seem to be supported by all compilers (too bad). Am
I missing something?
Extension:
- ptr<T> could be optimized for direct access when T is not virtual but this
would depend on __type_traits mainly or with other boost techniques;
- I don't see why compilers shouldn't integrate more information related on
classes hierarchy in their code.
I'm cleaning up the code but I just wanted mention the maximised areas.
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