Hasty Briefsbeta

Bilingual

C++: terser (shorter) lambda == SHORTY (ab-use?)

a year ago
  • #lambda
  • #C++
  • #syntax
  • The library 'shorty' provides a terser syntax than C++ lambdas, not replacing C++ but offering a more concise way to write expressions.
  • Examples include sorting with `$lhs > $rhs`, filtering even numbers with `($i % 2) == 0`, and zipping/transforming views.
  • Supports calling external functions like `$<sqrt>($a * $a + $b * $b)` and casting with `$<int>($0)`.
  • Special argument syntax includes `$lhs`, `$rhs`, `$it`, `$a` to `$f`, `$x`, `$y`, `$z`, `$i`, `$n`, `$k`, `$in`, `$argc`, and `$args`.
  • Capture options: `$(v)` or `$ref(v)` for reference, `$value(v)` or `$copy(v)` for copy, and `$fixed<v>` or `$const<v>` for CNTTP.
  • Supports calling callables or constructing new instances with `$<callable>(args...)` or `$call<CallableType>(args...)`.
  • Arithmetic operations like `$a += 2` are supported, along with other compound assignments.
  • Special thanks to an anonymous Argentinian for inspiring this project.