C++ Logo

std-discussion

Advanced search

Re: P1208R1 and the meaning of "call-site" for default non-type template parameters

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Tue, 18 Jan 2022 10:12:58 +0100
pon., 17 sty 2022 o 17:22 Xavier Roche via Std-Discussion
<std-discussion_at_[hidden]> napisaƂ(a):
>
> P1208R1 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1208r1.html)
> introduced a very neat std::source_location feature (which is not yet
> implemented by all compilers/libraries)
>
> A typical use of this new type will be involved:
> - in a default function argument with the "call site" filled by default
> - in a default struct/class member with the "call site" filled by default
>
> However, when used within a default non-type parameter of a template,
> it does not seem that the call site is the site instantiating the
> template itself, but the template location.
>
> Is this the expected behavior ? (Sorry if this is a rather silly question)
>
Probably yes, otherwise you will have multiple copies of the same
function and if we would use class templates then it would make it
nearly impossible
to use as every `type<>` will be different type.


> A very simple example:
> https://godbolt.org/z/jW54vx8Ef
>
> Regards,
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2022-01-18 09:13:07