Difficulties with std.variant.Algebraic

bearophile bearophileHUGS at lycos.com
Thu Jul 11 06:27:42 PDT 2013


Some example code:

import std.typecons;

Nullable!int unreliable1(in int val) pure nothrow {
     if (val == 0) {
         return typeof(return)();
     } else {
         return typeof(return)(val);
     }
}

Nullable!(int, 0) unreliable2(in int val) pure nothrow {
     if (val == 0) {
         return typeof(return)();
     } else {
         return typeof(return)(val);
     }
}

void main() {
     auto nx1 = unreliable1(10);
     auto nx2 = unreliable2(10);
}


Bye,
bearophile


More information about the Digitalmars-d-learn mailing list