Date: Sun, 3 Jul 2022 09:53:34 -0400
On Sun, Jul 3, 2022 at 8:49 AM Bo Persson via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On 2022-07-03 at 14:02, Frederick Virchanza Gotham via Std-Proposals wrote:
> >
> > Earlier this year on 25 March, I shared my idea to this mailing list of
> > using the 'explicit' keyword on template parameters as follows:
> >
> > template<explicit class T>
> > void Func(T &arg)
> > {
> > /* Do Something */
> > }
> >
> > The idea was that you would have to write:
> >
> > int main(void)
> > {
> > int i;
> >
> > Func<int>(i);
> > }
> >
> > because the 'explicit' keyword would prevent automatic deduction of the
> > type T.
> >
> > You can see my original post archived here:
> >
> > https://lists.isocpp.org/std-proposals/2022/03/3721.php
> > <https://lists.isocpp.org/std-proposals/2022/03/3721.php>
> >
> > That same week, another contributor made another suggestion that looked
> > similar to what I was suggesting, but which was very different in
> > functionality. My own suggestion I think got lost in the paperwork back
> > and forth, and so I would like to bring it to people's attention again
> > now, as I've shared the idea elsewhere and people seeming to be
> > overwhelming in support of it.
> >
>
> The standard already has type_identity, added specifically for this purpose.
Well yes, but that doesn't make the language feature a priori a bad
idea. After all, this is an idiom that has to be taught rather than
something that's easy to look up.
What makes the feature not worthwhile is both that the idiom exists
*and* that this isn't all that common. That is, while we do need the
ability to stop a function template parameter from being deduced, it
doesn't happen often enough to warrant being a language feature if
there is an alternative that isn't particularly cumbersome to use. And
`type_identity_t`, while not being very indicative of what's going on,
is good enough.
<std-proposals_at_[hidden]> wrote:
>
> On 2022-07-03 at 14:02, Frederick Virchanza Gotham via Std-Proposals wrote:
> >
> > Earlier this year on 25 March, I shared my idea to this mailing list of
> > using the 'explicit' keyword on template parameters as follows:
> >
> > template<explicit class T>
> > void Func(T &arg)
> > {
> > /* Do Something */
> > }
> >
> > The idea was that you would have to write:
> >
> > int main(void)
> > {
> > int i;
> >
> > Func<int>(i);
> > }
> >
> > because the 'explicit' keyword would prevent automatic deduction of the
> > type T.
> >
> > You can see my original post archived here:
> >
> > https://lists.isocpp.org/std-proposals/2022/03/3721.php
> > <https://lists.isocpp.org/std-proposals/2022/03/3721.php>
> >
> > That same week, another contributor made another suggestion that looked
> > similar to what I was suggesting, but which was very different in
> > functionality. My own suggestion I think got lost in the paperwork back
> > and forth, and so I would like to bring it to people's attention again
> > now, as I've shared the idea elsewhere and people seeming to be
> > overwhelming in support of it.
> >
>
> The standard already has type_identity, added specifically for this purpose.
Well yes, but that doesn't make the language feature a priori a bad
idea. After all, this is an idiom that has to be taught rather than
something that's easy to look up.
What makes the feature not worthwhile is both that the idiom exists
*and* that this isn't all that common. That is, while we do need the
ability to stop a function template parameter from being deduced, it
doesn't happen often enough to warrant being a language feature if
there is an alternative that isn't particularly cumbersome to use. And
`type_identity_t`, while not being very indicative of what's going on,
is good enough.
Received on 2022-07-03 13:55:33