www.digitalmars.com         C & C++   DMDScript  

c++.beta - template instantiation

#include <stdio.h>
#include <typeinfo>

template<class T>
struct A
  static void f()
    printf("%08x %s\n", &A::f, typeid(A).name());

int main()
  A<const int>::f();
  A<volatile int>::f();
  A<const volatile int>::f();

  A<int *>::f();
  A<int * const>::f();

  return 0;

Here is the output when compiled with DMC:

00402128 A<int >
0040214c A<>
00402170 A<>
00402194 A<>
004021b8 A<int *>
004021dc A<int *const >
004021dc A<int *const >
004021dc A<int *const >

The last three lines should all be different as these are distinct types
(note that 8.3.5 Functions [dcl.fct], paragraph 3 doesn't apply here).

Again, extracted from Boost's type_traits tests.

bye, Christof

http://cmeerw.org                                 JID: cmeerw jabber.at
mailto cmeerw at web.de

...and what have you contributed to the Net?
Jul 16 2003