Boost logo

Boost :

Subject: Re: [boost] [Any] Reference counting
From: Michael Howell (mhowell123_at_[hidden])
Date: 2009-04-05 21:06:46

Steven Watanabe <watanabesj_at_[hidden]> wrote:
> Have you read
I haven't read it, and have looked into atomic numbers, but couldn't find the
"Boost Way" to do it (except perhaps poking around with shared_ptr innards). I
wanted to use intrusive counts, since we have control over the object we are

Thorsten Ottosen <thorsten.ottosen_at_[hidden]> wrote:
>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.
I'll look into that.

Mathias Gaunard <mathias.gaunard_at_[hidden]> wrote:
> Also, any is a value type. We do not want it to have reference
> semantics. So you'd need to use COW.
Actually, copy on write/implicit sharing is what I was proposing, if you had
looked at the code.
> Hence this is fairly useless, especially since we're getting move
> semantics soon.
"Soon" is relative. The trunk GCC may support it instantly (may already), but
Debian Stable won't, nor will MSVC (both which will be used for a good while).
Also, you usually copy the value when you store it, which may or may not
involve writing. For example:
#include <boost/any.hpp>
using namespace boost;
struct example {
    any variable;
int main() {
    example object;
    example object2;
    any value = "I Love Boost!";
    object.variable = value;
    object2.variable = value;
    return 0;

Thanks for replying, everyone.

Michael Howell 

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