Closed mortenvp closed 5 years ago
If I understand the fix in #5 correctly the readme also contains a dangling reference to a lambda.
Nah, that's fine. The fixes to the tests were needed because of this:
tl::function_ref<void(void)> ref =
[]{} //this is an rvalue, so it will cease to exist after the semicolon
; //now ref dangles
ref(); //BOOM
But passing a lambda directly to a function_ref
parameter is fine, because:
void f(tl::function_ref<void(void)>);
f(
[]{} //this is an rvalue, so it will cease to exist after the semicolon
); //now the closure is dead, but since we only use it in `f`, it's all good
Of course if f
stored the function_ref somewhere it'd be a different story.
Does that make sense?
Makes sense :+1:
I think the previous version of the README.md has a dangling reference to the lambda.