Click here to Skip to main content
15,889,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone please explain me the meaning of the statement given below

C++
template <typename T, int N>
char (&array(T(&)[N]))[N];
Posted
Updated 30-Apr-10 2:54am
v2

1 solution

Its a explicit template specialization.
There are two types of template specialization

1. Explicit
C++
template<> void sort<char*>(Array<char*>&);

2. Partial
template<class T1, class T2, int I>
  class A             { };             

We can specialize this for the case when T2 is a T1*:
template<class T, int I>
class A<T, T*, I>   { };

Or for the case when T1 is any pointer:
template<class T1, class T2, int I>
class A<T1*, T2, I> { };

Or for the case when T1 is int and T2 is any pointer and I is 5:
template<class T>
class A<int, T*, 5> { };

Or for the case when T2 is any pointer:
template<class T1, class T2, int I>
class A<T1, T2*, I> { };

Declarations 2 to 5 declare partial specializations of the primary template.

[edit]Fixed so that all the angle brackets show[/edit]
[edit:rjm]added <pre> tags[/edit]
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900