0

Possible Duplicate:
Template instantiation details of GCC and MS compilers

  1. How does a C++ compiler facilitate template programming? I am interested in knowing the scheme that the compiler follows in template programming.

  2. Also, what is/are the difference(s) between typename and class in terms of C++ template?

Community
  • 1
  • 1

2 Answers2

1

How does a C++ compiler facilitate template programming? I am interested in knowing the scheme that the compiler follows in template programming.

templates are actually kept by the compiler as some kind of macro, which is then expanded (the template parts are replaced with given values) upon specialization, applying constraint checking specified in the template.

LeleDumbo
  • 9,192
  • 4
  • 24
  • 38
0

Also, what is/are the difference(s) between typename and class in terms of C++ template?

No difference, except when you use template-template parameters:

 template <template <typename> class T>
 ...

cannot be replaced by

 template <template <typename> typename T>
 //                            ^^^^^^^^ wrong
 ...

More in Templates in c++,typename and class.

Community
  • 1
  • 1
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005