20-Nov-2013 22:01, Simen Kjærås пишет:
On 20.11.2013 18:45, Simen Kjærås wrote:
[snip]
May I suggest:

struct Validated(alias fn, T) {
     private T value;
     @property inout
     T get() {
         return value;
     }

Uh-hm. Add this:
        alias get this;


And it decays to the naked type in a blink of an eye. And some function down the road will do the validation again...

}

Validated!(fn, T) validate(alias fn, T)(T value) {
     Validated!(fn, T) result;
     fn(value);
     result.value = value;
     return result;
}

void functionThatTakesSanitizedFileNames(Validated!(sanitizeFileName,
string) path) {
    // Do stuff
}





--
Dmitry Olshansky

Reply via email to