Discussion:
Missing of an example of using typename with a non-type template parameter.
(too old to reply)
'Vlad from Moscow' via ISO C++ Standard - Discussion
2018-10-18 15:49:01 UTC
Permalink
In the section 17.1 Template parameters (p.#2) there is written

...typename followed by an unqualified-id names a template type parameter. t*ypename
followed by a qualified-id denotes the type in a non-type136
parameter-declaration*.
However the example that follows the paragraph does not show such a
feature. That is according to the quote it seems that this code is valid

#include <iostream>


typedef int T;


template <typename ::T N>
struct A
{
std::ostream & operator ()( std::ostream &os = std::cout ) const
{
for ( ::T i = 0; i < N; i++ ) os << i << ' ';
return os;
}
};


int main()
{
A<10>()() << '\n';
}


I think that it would be reasonable to add an example under the quote of
using a template header like *template <typename ::T N>*
--
---
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/.
'Vlad from Moscow' via ISO C++ Standard - Discussion
2018-10-19 16:08:58 UTC
Permalink
If the code example I showed in the previous message is correct then the
quote looks like incorrect .:)

There is written in the quote that

2 There is no semantic difference between class and typename in a
type-parameter-key.
However according to the gcc you may not substitute typename in a
template-head for class like *template <class ::T N>. *

So it follows that there is a semantic difference between class and
typename in a type-parameter-key.:)

четверг, 18 Пктября 2018 г., 18:49:01 UTC+3 пПльзПватель Vlad from Moscow
In the section 17.1 Template parameters (p.#2) there is written
...typename followed by an unqualified-id names a template type parameter.
t*ypename followed by a qualified-id denotes the type in a non-type136
parameter-declaration*.
However the example that follows the paragraph does not show such a
feature. That is according to the quote it seems that this code is valid
#include <iostream>
typedef int T;
template <typename ::T N>
struct A
{
std::ostream & operator ()( std::ostream &os = std::cout ) const
{
for ( ::T i = 0; i < N; i++ ) os << i << ' ';
return os;
}
};
int main()
{
A<10>()() << '\n';
}
I think that it would be reasonable to add an example under the quote of
using a template header like *template <typename ::T N>*
--
---
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:33:07 UTC
Permalink
Nope, because that is not a type-parameter-key. (It's a non-type parameter
and as such the sentence doesn't apply as there is no type-parameter-key).

On Fri, Oct 19, 2018, 6:09 PM 'Vlad from Moscow' via ISO C++ Standard -
Post by 'Vlad from Moscow' via ISO C++ Standard - Discussion
If the code example I showed in the previous message is correct then the
quote looks like incorrect .:)
There is written in the quote that
2 There is no semantic difference between class and typename in a
type-parameter-key.
However according to the gcc you may not substitute typename in a
template-head for class like *template <class ::T N>. *
So it follows that there is a semantic difference between class and
typename in a type-parameter-key.:)
четверг, 18 Пктября 2018 г., 18:49:01 UTC+3 пПльзПватель Vlad from Moscow
In the section 17.1 Template parameters (p.#2) there is written
...typename followed by an unqualified-id names a template type
parameter. t*ypename followed by a qualified-id denotes the type in a
non-type136 parameter-declaration*.
However the example that follows the paragraph does not show such a
feature. That is according to the quote it seems that this code is valid
#include <iostream>
typedef int T;
template <typename ::T N>
struct A
{
std::ostream & operator ()( std::ostream &os = std::cout ) const
{
for ( ::T i = 0; i < N; i++ ) os << i << ' ';
return os;
}
};
int main()
{
A<10>()() << '\n';
}
I think that it would be reasonable to add an example under the quote
of using a template header like *template <typename ::T N>*
--
---
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/.
'Vlad from Moscow' via ISO C++ Standard - Discussion
2018-10-19 16:39:46 UTC
Permalink
Maybe in this case it would be reasonable to update the quote the following
way.

2 There is no semantic difference between class and typename in a
type-parameter-key. typename followed by an unqualified-id is a
type-parameter-key and names a template type parameter. typename followed
by a qualified-id is not a type-parameter-key and denotes the type in a
non-type136 parameter-declaration. A template-parameter of the form class
identifier is a type-parameter.
пятМОца, 19 Пктября 2018 г., 19:33:22 UTC+3 пПльзПватель Nicolas Lesser
Nope, because that is not a type-parameter-key. (It's a non-type parameter
and as such the sentence doesn't apply as there is no type-parameter-key).
On Fri, Oct 19, 2018, 6:09 PM 'Vlad from Moscow' via ISO C++ Standard -
Post by 'Vlad from Moscow' via ISO C++ Standard - Discussion
If the code example I showed in the previous message is correct then the
quote looks like incorrect .:)
There is written in the quote that
2 There is no semantic difference between class and typename in a
type-parameter-key.
However according to the gcc you may not substitute typename in a
template-head for class like *template <class ::T N>. *
So it follows that there is a semantic difference between class and
typename in a type-parameter-key.:)
четверг, 18 Пктября 2018 г., 18:49:01 UTC+3 пПльзПватель Vlad from Moscow
In the section 17.1 Template parameters (p.#2) there is written
...typename followed by an unqualified-id names a template type
parameter. t*ypename followed by a qualified-id denotes the type in a
non-type136 parameter-declaration*.
However the example that follows the paragraph does not show such a
feature. That is according to the quote it seems that this code is valid
#include <iostream>
typedef int T;
template <typename ::T N>
struct A
{
std::ostream & operator ()( std::ostream &os = std::cout ) const
{
for ( ::T i = 0; i < N; i++ ) os << i << ' ';
return os;
}
};
int main()
{
A<10>()() << '\n';
}
I think that it would be reasonable to add an example under the quote
of using a template header like *template <typename ::T N>*
--
---
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/.
Continue reading on narkive:
Loading...