digitalmars.D - [Phobos request] Op template
Hi ! I've found that next template will be convenient for use in chains and cetera. Op!`+` == (a, b) => a + b For example: auto sum = arr.fold!(Op!`+`). Suggests ?
Jul 06 2016
On Wednesday, 6 July 2016 at 17:17:41 UTC, Temtaime wrote:Hi ! I've found that next template will be convenient for use in chains and cetera. Op!`+` == (a, b) => a + b For example: auto sum = arr.fold!(Op!`+`). Suggests ?There's a couple templates that can be defined to cover the range of operators. alias binop(string s) = (a, b) => mixin("a" ~ s ~ "b"); alias preop(string s) = a => mixin(s ~ "a"); alias postop(string s) = a => mixin("a" ~ s);
Jul 06 2016