assert() vs. enforce(), invariant() vs. ... ?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Aug 29 07:55:43 PDT 2013


On 29/08/13 16:21, Artur Skawina wrote:
> In order to handle ref-returns it would have to be more like
>
>     struct EnforceWrapper(T) {
>        T t;
>
>        auto ref opDispatch(string M, Args...)(Args args) {
>           {/*before code*/}
>           scope (exit) {/*after code*/}
>           return mixin("t." ~ M ~ "(args)");
>        }
>     }
>
> and need another two overloads for property/field getters and
> setters. Handling ref-args would add more complexity, but in
> many cases ignoring them or using auto-ref is enough.

Interesting.  When it comes down to it, it looks like what you're proposing is 
an extended version of Proxy, no .... ?



More information about the Digitalmars-d mailing list