Boost logo

Boost :

From: Bohdan (warever_at_[hidden])
Date: 2002-11-22 15:21:53

I really want to know how good is any. Can it be used in
applications which require speed for "variant type" ?
I can see two problems:

1. frequently accessed small objects (int,float...).
       This category doesn't like "virtual function" nature of any.
   To avoid virtual functions i can see no other way but using some
   other variant type (union?).

2. big objects.
Cloning can be expensive. Common approach is to assign object pointer
to any. But in this case we can simly avoid object pointer "boxing"
by makeing placeholder class public and allow user to
inherit from it. Than:

any var;
//if( BigObject is inherited from any::palaceholder )
// than content=pointer
// else content=box(pointer);
var = new BigObject;

This approach requires refcounting for placeholder to
destroy object pointed by any::content correctly.
BTW, this is how c# object works, but GC is used in place of ref-counting.
I suspect this was already concidered and rejected,
than can anybody shed light why ?


Boost list run by bdawes at, gregod at, cpdaniel at, john at