Subject: Re: [boost] [log] Comments
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-03-16 11:57:02


AMDG

Andrey Semashev wrote:
> On 03/16/2010 02:02 AM, Steven Watanabe wrote:
>> Andrey Semashev wrote:
>>> but with extract it doesn't have the copyability restriction.
>>
>> Why does this require System to be copyable? Can't you
>> return a reference?
>
> Returning a reference looks like an unsafe interface design to me.
> Remember that double dispatch is taken place here, so that the
> caller's visitor is invoked by the attribute value, with a reference
> to the actual value. In order to return this reference from
> get_nothrow, it has to be saved by the visitor and restored after
> returning from the attribute value dispatch method. At this point the
> reference may potentially be broken.

Then I consider your dispatcher interface to be the unsafe thing.
Is there a good reason to allow the attribute value to be constructed
on the fly every time it's needed? The only built-in attribute that does
this is the current_thread_id attribute, and I don't see a problem
with saving the current thread id when getting the attribute's value.

In Christ,
Steven Watanabe