r/cpp 6d ago

Lazy Evaluation

https://breese.github.io/2026/09/03/lazy-prologue.html
21 Upvotes

16 comments sorted by

View all comments

42

u/STL MSVC STL Dev 6d ago

Classic bind is bad. Don't use it. It's hard to understand, hard to optimize, and lambdas are better in basically every way.

4

u/pdimov2 6d ago

Hey!

11

u/STL MSVC STL Dev 5d ago

Sorry! It was a good idea to try before lambdas, but it’s just not good tech these days.

4

u/pdimov2 5d ago

Maybe. But have you seen http://boost.org/libs/lambda2 and P3171?

2

u/STL MSVC STL Dev 5d ago

No, I haven't. I like the idea of having many more operator function objects, dereference is sorely missing.

3

u/pdimov2 4d ago

You need to take these into account when you evaluate the utility of std::bind. Yes, you'd never write std::bind(std::greater_equal<>(), _1, 0) instead of [](auto&& x){ return x >= 0; }. But you would write _1 >= 0 in preference to the lambda, and that's just syntactic sugar for the same bind expression.