emplace, scope, enforce [Was: Re: Manual...]

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Jul 22 12:16:01 PDT 2010


On 22.07.2010 2:27, Andrei Alexandrescu wrote:
> On 07/21/2010 03:35 PM, Dmitry Olshansky wrote:
>> Thanks for kind feedback (and showing some optimization tricks). Also
>> this implementation still has issues with it: it calls dtor twice. Not a
>> good trait for RAII technique ! :)
>> Since it's now considered useful I feel myself obliged to enhance and
>> correct it. Sadly enough I still haven't managed to apply an inner
>> template trick.
>> Here's the end result along with a simple unittest:
> [snip]
>
> The double destructor hits a bug in the compiler implementation. 
> Anyway, here's the committed code:
>
> http://www.dsource.org/projects/phobos/changeset/1774
>
> It uses a new idiom that is enabled by auto returns - defines a struct 
> inside the function and returns it. That's a veritable existential 
> type! 
> (http://stackoverflow.com/questions/292274/what-is-an-existential-type) I 
> expect more of that idiom in the upcoming commits.
>
A cool idiom indeed!

I guess I should clarify the double destruction problem: it was caused 
by static opCall, the current implementation in Phobos does not suffers 
from it.

-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list