Date: Thu, 20 Apr 2023 12:09:05 +0100
Was it the intention of the Committee from the outset that it should
not be possible to create a lambda object outside of the function in
which the lambda type is defined? See the following two snippets:
auto Func(void)
{
auto mylambda = [](void)->int { return 27u; };
return *decltype(&mylambda)(nullptr);
}
typedef decltype(Func()) LambdaType;
int main(void)
{
LambdaType mylambda;
mylambda();
}
And also:
template<typename T>
void Func(T &arg)
{
T obj;
}
int main(void)
{
auto mylambda = [](void)->int { return 27u; };
Func(mylambda);
}
Was this kind of thing not supposed to be done? Or is it okay?
not be possible to create a lambda object outside of the function in
which the lambda type is defined? See the following two snippets:
auto Func(void)
{
auto mylambda = [](void)->int { return 27u; };
return *decltype(&mylambda)(nullptr);
}
typedef decltype(Func()) LambdaType;
int main(void)
{
LambdaType mylambda;
mylambda();
}
And also:
template<typename T>
void Func(T &arg)
{
T obj;
}
int main(void)
{
auto mylambda = [](void)->int { return 27u; };
Func(mylambda);
}
Was this kind of thing not supposed to be done? Or is it okay?
Received on 2023-04-20 11:09:17