brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 512ea47 Raw
62 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3struct IntHolder {4  IntHolder(int);5};6 7template<typename T, typename U>8struct X {9  void f() { 10    T t;11  }12  13  void g() { }14  15  struct Inner { 16    T value; 17  };18  19  static T value;20};21 22template<typename T, typename U>23T X<T, U>::value;24 25// Explicitly specialize the members of X<IntHolder, long> to not cause26// problems with instantiation, but only provide declarations (not definitions).27template<>28void X<IntHolder, long>::f();29 30template<>31struct X<IntHolder, long>::Inner; // expected-note{{forward declaration}}32 33template<>34IntHolder X<IntHolder, long>::value;35 36IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) {37  xih.g(); // okay38  xih.f(); // okay, uses specialization39  40  X<IntHolder, long>::Inner inner; // expected-error {{incomplete}}41  42  return X<IntHolder, long>::value; // okay, uses specialization43}44 45 46template<class T> struct A {47  void f(T) { /* ... */ }48};49 50template<> struct A<int> { 51  void f(int);52};53 54void h() {55  A<int> a; 56  a.f(16); // A<int>::f must be defined somewhere57}58 59// explicit specialization syntax not used for a member of 60// explicitly specialized class template specialization 61void A<int>::f(int) { /* ... */ }62