Boost logo

Boost :

From: Ruslan Zasukhin (sunshine_at_[hidden])
Date: 2002-02-08 06:08:50


Hi Bosters,

Question to developers of auto_ptr<> in BOOST.

Do you know that exists implementation of counter ptr,
That is more effective that your auto_ptr<> ?

It is in CodeWarrior.

Idea is split it on 2 classes
    
    Sharable { ulong refCount; }
    SharablePtr<t> { T* ptr_ }

Usually we have

    1 sharable object
    MANY pointers to it.

Your auto_ptr<> has size 8 bytes: ptr and ptr to counter.
So if we have 100 pointers around object, you use

        4 -- counter
        100 * 8 = 800 pointers.
   
In above implementation
    
        4 counter
        100 * 4 = 400 bytes pointers.

IF to think about passing of SharablePtr<t> to/from function,
then it is effective 100% the same as normal C++ pointer. Wow.

And ... While I have type this letter it seems I have got idea!

For now in Valentina I use auto_ptr<> in sense of your scope_ptr<>.
And I have separate classes for Sharable and SharablePtr.

BUT, may be it is possible make just specialization of auto_ptr<>
In case it point on sub-classes of Sharable?

    template<>
    auto_ptr<Sharable*>
    {
        // for such pointer we use only 4 bytes:
        Sharable* ptr_;
    };
 
What you think guys ?

-- 
Best regards,
Ruslan Zasukhin
-------------------------
Paradigma.
e-mail: ruslan_at_[hidden]
web   : http://www.paradigmasoft.com
To subscribe to the Valentina mail list
send a letter to valentina-on_at_[hidden]

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