C++ Logo

std-discussion

Advanced search

Re: CNTTP defaulted to lambda in definition produces different type every time

From: Brian Bi <bbi5291_at_[hidden]>
Date: Thu, 27 Apr 2023 11:26:11 -0400
On Thu, Apr 27, 2023 at 11:19 AM Daniel Krügler <daniel.kruegler_at_[hidden]>
wrote:

> Am Do., 27. Apr. 2023 um 17:14 Uhr schrieb Brian Bi <bbi5291_at_[hidden]>:
> >
> >
> > On Thu, Apr 27, 2023 at 11:08 AM Daniel Krügler via Std-Discussion <
> std-discussion_at_[hidden]> wrote:
> >>
> >> Am Do., 27. Apr. 2023 um 17:05 Uhr schrieb Thiago Macieira via
> >> Std-Discussion <std-discussion_at_[hidden]>:
> >> >
> >> > Is this intended with C++20's class-type NTTPs?
> >>
> >> No,
> >>
> >> see
> >>
> >> https://cplusplus.github.io/CWG/issues/cwg_active.html#2542
> >
> >
> > But this doesn't really answer the OP's question.
>
> Why not? The OP example uses a lambda closure as NTTP, so why does my
> response not answer the OP's question?
>
> > Consider that we can simply do this:
> >
> > template <class T> struct Structural {};
> >
> > template <auto Call = Structural<decltype([]{})>{}> struct S {};
> >
> > Now the template parameter type is structural, but there is still a
> question of whether the lambda type is the same every time `S<>` is
> referenced.
> >
>
> This seems to be a different question.
>

I think the question that the OP meant to ask is whether a lambda
expression appearing in a default template argument has the same type every
time the default template argument gets used. (See the subject line.)

My take is that if the code has some bug unrelated to what the OP meant to
ask, one should point out the bug but also answer what they meant to ask.
Pointing out CWG 2542 accomplishes the first part of this, but not the
second.


>
> - Daniel
>


-- 
*Brian Bi*

Received on 2023-04-27 15:26:26