improving scope(finally/success)
Artur Skawina via Digitalmars-d
digitalmars-d at puremagic.com
Fri Dec 4 00:32:55 PST 2015
On 12/03/15 16:33, Steven Schveighoffer via Digitalmars-d wrote:
> auto ref logCall(alias f, Args...)(auto ref Args args) {
> auto ref printResult(T)(auto ref T t)
> {
> writeln(t);
> return t;
> }
> return printResult(f(args))
> }
>
> logCall!foo(true);
Which will happily accept:
bool foo(ref bool a) { return a=false; }
And, yes, it can be dealt with via a bit of introspection, but
nobody will bother in practice (consider that 'f' may be
overloaded). So it doesn't really work for non-trivial or
generic code.
artur
More information about the Digitalmars-d
mailing list