Date: Wed, 15 Nov 2023 13:45:39 +0000
On Wed, Nov 15, 2023 at 1:39 PM Pavel Vazharov <freakpv_at_[hidden]> wrote:
>
> As far as I know the standard mandates that every lambda has a unique type.
> I don't think that the compiler is allowed to do the "collapsing" of the "same" lambda objects to a single type but I can't prove it as I'm not so versed with the C++ standard.
Yeah every lambda must have a unique type:
int main(void)
{
auto lambda1 = []{};
auto lambda2 = []{};
static_assert( false == std::is_same_v< decltype(lambda1),
decltype(lambda1) > );
}
I'm not saying that two lambdas might have the same type. The above
static_assert must always succeed. What I'm saying is: When the
compiler encounters:
template<typename = decltype([]{})>
Is the compiler free to have one global lambda type that is shared as
a default template parameter among all the instantiations?
>
> As far as I know the standard mandates that every lambda has a unique type.
> I don't think that the compiler is allowed to do the "collapsing" of the "same" lambda objects to a single type but I can't prove it as I'm not so versed with the C++ standard.
Yeah every lambda must have a unique type:
int main(void)
{
auto lambda1 = []{};
auto lambda2 = []{};
static_assert( false == std::is_same_v< decltype(lambda1),
decltype(lambda1) > );
}
I'm not saying that two lambdas might have the same type. The above
static_assert must always succeed. What I'm saying is: When the
compiler encounters:
template<typename = decltype([]{})>
Is the compiler free to have one global lambda type that is shared as
a default template parameter among all the instantiations?
Received on 2023-11-15 13:45:52