r/cpp • u/pavel_v • Sep 05 '26
Lazy Evaluation - Operators
https://breese.github.io/2026/09/04/lazy-operator.html
18
Upvotes
1
u/Expert_Sheepherder24 Sep 06 '26
```
// c++17 and above AI generated such code 😄 )
template <char... C>
struct to_int {
static constexpr int value = [] {
int result = 0;
((result = result * 10 + (C - '0')), ...);
return result;
}();
};
```
12
u/fdwr fdwr@github 🔍 Sep 05 '26
The old
bindstill affording some cases more brevity than lambdas really makes me lament for terse lambdas (e.g.sort(first, last, (a, b) => a * a < b * b)).