[phobos] Proposal of StopWatch module

Jonathan M Davis jmdavisprog at gmail.com
Fri Aug 20 18:33:59 PDT 2010


On Friday, August 20, 2010 18:11:53 Andrei Alexandrescu wrote:
> >> Line 762: Beautiful idiom!
> > 
> > Thanks! But, I want to write like this:
> > with (measureTime!((a){assert(a.seconds);}))
> > {
> > doSomething();
> > }
> > 
> > I don't want to name a nonuse variable.
> > In this usage, I think that With is proper.
> > But, this doesn't call destructor. (for bug 3516?
> > Though I think that how to use is free.
> 
> It's definitely a bug. But note that in C++ an unused value will be
> destroyed at the end of expression, which makes sense. That means your
> idiom would need a named variable.

It is a very good idiom though.

- Jonathan M Davis


More information about the phobos mailing list