Discussion:
Default template argument in type-parameter definition and in constrained-parameter definition.
(too old to reply)
'Vlad from Moscow' via ISO C++ Standard - Discussion
2018-10-19 16:34:00 UTC
Permalink
The type-parameter is defined in particularly the following way

type-parameter:
type-parameter-key identifieropt = type-id

On the other hand, the constrained-parameter is defined like

constrained-parameter:

qualified-concept-name identifieropt default-template-argumentopt

Then in the corresponding section there is written (p.#12):

12 A default template-argument is a template-argument (17.3) specified
after = in a template-parameter. A default template-argument may be
specified for any kind of template-parameter (type, non-type, template)
that is not a template parameter pack (17.6.3).
Would it be more logically consisten to define the type-parameter like

type-parameter:

type-parameter-key identifieropt default-template-argumentopt

and then in some paragraph to elaborate that for the type-parameter the
default-template-argument is type-id?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Nicolas Lesser
2018-10-19 16:39:01 UTC
Permalink
Meh, I guess we could do that. But I'd wait for when C++20 is finalized, as
the committee hasn't decided on an abbreviated constraint parameter if you
know what I mean.

The grammar might change.

On Fri, Oct 19, 2018, 6:34 PM 'Vlad from Moscow' via ISO C++ Standard -
Post by 'Vlad from Moscow' via ISO C++ Standard - Discussion
The type-parameter is defined in particularly the following way
type-parameter-key identifieropt = type-id
On the other hand, the constrained-parameter is defined like
qualified-concept-name identifieropt default-template-argumentopt
12 A default template-argument is a template-argument (17.3) specified
after = in a template-parameter. A default template-argument may be
specified for any kind of template-parameter (type, non-type, template)
that is not a template parameter pack (17.6.3).
Would it be more logically consisten to define the type-parameter like
type-parameter-key identifieropt default-template-argumentopt
and then in some paragraph to elaborate that for the type-parameter the
default-template-argument is type-id?
--
---
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at
https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Richard Smith
2018-10-19 19:29:09 UTC
Permalink
On Fri, 19 Oct 2018 at 09:34, 'Vlad from Moscow' via ISO C++ Standard -
Post by 'Vlad from Moscow' via ISO C++ Standard - Discussion
The type-parameter is defined in particularly the following way
type-parameter-key identifieropt = type-id
On the other hand, the constrained-parameter is defined like
qualified-concept-name identifieropt default-template-argumentopt
12 A default template-argument is a template-argument (17.3) specified
after = in a template-parameter. A default template-argument may be
specified for any kind of template-parameter (type, non-type, template)
that is not a template parameter pack (17.6.3).
Would it be more logically consisten to define the type-parameter like
type-parameter-key identifieropt default-template-argumentopt
and then in some paragraph to elaborate that for the type-parameter the
default-template-argument is type-id?
That's a breaking change. Consider:

struct X {};
template<X x = X()> struct A {};

Today, this is unambiguously a declaration of a non-type template parameter
whose default argument is a default-constructed X.

With your grammar change, because a default-template-argument (or a
template-argument generally) is parsed without the context of the kind
(type/non-type/template) of the parameter, the X() would instead be
interpreted as a function type, and the example above is ill-formed.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Continue reading on narkive:
Loading...