[Any] Reference counting

The attached patch add reference counting "implicit sharing" to Boost.Any. It is my first patch to Boost, so it will probably need some changes. -- Michael Howell mhowell123@gmail.com

AMDG Michael Howell wrote:
The attached patch add reference counting "implicit sharing" to Boost.Any. It is my first patch to Boost, so it will probably need some changes.
Have you read http://www.gotw.ca/gotw/045.htm? In Christ, Steven Watanabe

On Saturday 04 April 2009 15:17:11 you wrote:
The attached patch add reference counting "implicit sharing" to Boost.Any. It is my first patch to Boost, so it will probably need some changes. I know that self-replying is considered bad, but I've already managed to find some problems with it. New patch attached.
-- Michael Howell mhowell123@gmail.com

Michael Howell skrev:
The attached patch add reference counting "implicit sharing" to Boost.Any. It is my first patch to Boost, so it will probably need some changes.
If you want to improve the performance of any, the thing to do is to add a small buffer optimization such that all buildin types (or equally small UDT) are created on the stack. See http://www.codeproject.com/KB/cpp/dynamic_typing.aspx -Thorsten

Michael Howell wrote:
The attached patch add reference counting "implicit sharing" to Boost.Any. It is my first patch to Boost, so it will probably need some changes.
This code is not thread-safe. Just use shared_ptr. Also, any is a value type. We do not want it to have reference semantics. So you'd need to use COW. The thing about COW is that it is only useful if you copy when you don't need it. But why copy in the first place if you don't need it? Hence this is fairly useless, especially since we're getting move semantics soon.

Hi. Mathias Gaunard wrote:
Just use shared_ptr.
I create "Holder" what use shared_ptr to share instance. http://www.boostpro.com/vault/index.php?action=downloadfile&filename=holder.zip&directory=Data%20Structures& "Holder" likes boost::any, but this class has several semantics. - value semantics (like boost::any) - share semantics (like boost::shared_ptr) - noncopyable semantics - reference semantics (reference other object) and user can create custom containers to fit special class and semantics. Regards. Nowake
participants (5)
-
Mathias Gaunard
-
Michael Howell
-
Nowake
-
Steven Watanabe
-
Thorsten Ottosen