I am relatively new to C++(14) . And i am working on enhancing my current knowledge by reading through the official documentation from cpprefernce . I have some questions about template declaration : This page gives the following possible parameters(non-type template parameter) in the declarations for a class template .
type name(optional) // (1)
My question is :
1.)What is meant by type name
? I am sure it is not same as typename
mentioned here.
Further on the same page , i see the example :
// simple non-type template parameter
template<int N>
struct S { int a[N]; };
However from //1
, i see the type name is optional , so i hypothesis the below should work but it does not:(Indeed i see the below declaration template<N>
can be seen as template argument with type param.) \
// simple non-type template parameter
template<N>
struct S { int a[N]; };
So where is my understanding/reading of official docs is going wrong ?
Edit :
I tried the following :
template< int>
struct S { int a[N]; };
which does not compile with the error 'N' was not declared in the scope
.