this is a library implementation based on the with expression[1] idea
i posted a while ago and is kinda related to the ?. operator.

as we cant fully implement the above idea as a library i tried to do
what's possible which are basically chainable scopes[2].
implemented as 2 templates:

unchecked version: takes a Type and calls fun(type),
returns either type or return type of fun

auto call(alias fun, T)(T type)

checked version: takes a Type, does a check and if true, calls fun(type),
returns either type, return type of fun or ReturnType!(fun!T).init

auto checkCall(alias fun, T)(T type, T falseValue = T.init)

as im not an expert, are there any possible improvements?

(long post, only the top part is important the rest are just examples) [1] http://forum.dlang.org/thread/zgzgdknkeyahlbypi...@forum.dlang.org

[2] https://dpaste.dzfl.pl/5ecc288f572c

Reply via email to