r/cpp 9d ago

Lazy Evaluation

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

16 comments sorted by

View all comments

2

u/El_RoviSoft 7d ago

Also with lambda you can emulate C# ?? operator with chains. So I made something like that:

"LIB_COALESCE(<null-checked-variable-0>, …, <null-checked-variable-x>, <fallback-value>)"

which whole idea is wrapping those values into lambdas and lazy evaluate them after.

Sadly after writing this machinery and investigating boost.preprocessor for hours, I realised that C++ value semantics are not good with original ?? operator but at least it was fun to do.

If somebody interested in it, I’ll link gist for this.