templates - Maybe types in D -
i'm trying define value type either holds size_t
or null
(which mean 'maybe type'). want able (where relevant type maybe!size_t
:
maybe!size_t something_which_could_fail (int foo) { if (foo < 0) { return null;} else { return foo;} }
how implement such thing? ideally, able make template (so have other maybe
types well), , have conversions maybe non-maybe types possible above (although don't mind typecasting if not possible). nice if this:
maybe!size_t = 50; maybe!size_t b = null;
what nullable type in phobos library? http://dlang.org/phobos/std_typecons.html#.nullable
and other info in d forum: d forum thread option(maybe) type
Comments
Post a Comment