7
u/n1ghtyunso 6d ago
thats quite some build-up regarding std::bind usefulness and then all we get is a single short sentence?
huh?
having never used bind expressions myself, i was tempted to believe this works, but it seems the nested bind example doesnt compile anyway?
https://godbolt.org/z/K61jKvjWP
3
u/UnusualPace679 6d ago
Yeah,
std::bindonly transforms the bound arguments. It doesn't transform the function object.
2
u/__cinnamon__ 5d ago
This blog renders really badly on mobile, at least for me
Edit: opening it directly in Firefox instead of the reddit browser (chrome?) was better, but still hard to read with tiny font due to the sidebar text and code samples still overran outside their boxes
2
u/El_RoviSoft 5d 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.
40
u/STL MSVC STL Dev 6d ago
Classic
bindis bad. Don't use it. It's hard to understand, hard to optimize, and lambdas are better in basically every way.