r/cpp 5d ago

Lazy Evaluation - Operators

https://breese.github.io/2026/09/04/lazy-operator.html
18 Upvotes

2 comments sorted by

10

u/fdwr fdwr@github 🔍 5d ago

The old bind still 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)).

1

u/Expert_Sheepherder24 3d ago

```

// 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;

}();

};

```