--- /dev/null
+// Build don't link:
+
+template<class E> class D
+{
+};
+
+template<template<class> class D,class E> class C
+{
+};
+
+int main()
+{
+ C<int,D> c; // ERROR - args not match
+}
--- /dev/null
+// Build don't link:
+
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D d; // ERROR - D is a template
+ public:
+ int f();
+};
+
+template<template<class> class D,class E> int C<D,E>::f()
+{
+ return d.f(); // ERROR - d not properly declared
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { return d.f(); }
+};
+
+int main()
+{
+ C<D,int> c;
+ C<D,char> d;
+ c.f();
+ d.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class E,class D> class C
+{
+ E<D> d;
+ public:
+ int f();
+};
+
+template<template<class> class E,class D> int C<E,D>::f()
+{
+ return d.f();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f();
+};
+
+template<template<class> class D,class E> int C<D,E>::f()
+{
+ return d.f();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ T a;
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<class E,template<class> class DD = D> class C
+{
+ DD<E> d;
+ public:
+ int f();
+};
+
+template<class E,template<class> class DD = D> int C<E,DD>::f()
+{
+ DD<E> d2;
+ return d2.f();
+}
+
+int main()
+{
+ C<int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f();
+};
+
+template<template<class> class D,class E> int C<D,E>::f()
+{
+ D<E> d2;
+ return d2.f();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ T a;
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f();
+};
+
+template<template<class> class D,class E> int C<D,E>::f()
+{
+ D<E> d2;
+ return d2.f();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f();
+ int g() { return 0; }
+};
+
+template<template<class> class D,class E> int C<D,E>::f()
+{
+ C<D,E> d2;
+ return d2.g();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f();
+ int g() { return 0; }
+};
+
+template<template<class> class D,class E> int C<D,E>::f()
+{
+ C<D,char> d2;
+ return d2.g();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+#include <vector>
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int size() { return d.size(); }
+};
+
+template<template<class> class D,class E> int size(D<E> &d1)
+{
+ d1.size();
+ C<D,E> d2;
+ d2.size();
+ return 0;
+}
+
+int main()
+{
+ std::vector<int> c1;
+ std::vector<char> c2;
+ size(c1);
+ size(c2);
+}
--- /dev/null
+// Build don't link:
+
+template<class E> class D
+{
+};
+
+template<template<class> class D,int> class C
+{
+};
+
+int main()
+{
+ C<1,D> c; // ERROR - args not match
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C : D<E>
+{
+ public:
+ int g();
+};
+
+template<template<class> class D,class E> int C<D,E>::g()
+{
+ return f();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.g();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C : D<E>
+{
+ public:
+ int g();
+};
+
+template<template<class> class D,class E> int C<D,E>::g()
+{
+ return f();
+}
+
+class E : C<D,int>
+{
+ public:
+ int h() { return g(); }
+};
+
+int main()
+{
+ E c;
+ c.h();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class DD,class EE> class C : DD<EE>
+{
+ public:
+ int f();
+};
+
+template<template<class> class DD,class EE> int C<DD,EE>::f()
+{
+ return DD<EE>::f();
+}
+
+class E : C<D,int>
+{
+ public:
+ int f() { return C<D,int>::f(); }
+};
+
+int main()
+{
+ E c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class E,class D> class C : E<D>
+{
+ public:
+ int f();
+};
+
+template<template<class> class E,class D> int C<E,D>::f()
+{
+ return E<D>::f();
+}
+
+class E : C<D,int>
+{
+ public:
+ int f() { return C<D,int>::f(); }
+};
+
+int main()
+{
+ E c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> int f()
+{
+ D<E> d;
+ return d.f();
+};
+
+int main()
+{
+ f<D,int>();
+ f<D,char>();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { return d.f(); }
+};
+
+template<template<class> class D,class E> int f(D<E> &d1)
+{
+ d1.f();
+ C<D,E> d2;
+ d2.f();
+ return 0;
+}
+
+int main()
+{
+ D<int> c1;
+ D<char> c2;
+ f(c1);
+ f(c2);
+}
--- /dev/null
+template<class T, class U = int> class D
+{
+ public:
+ int f();
+};
+
+template<class T, class U> int D<T,U>::f()
+{
+ return sizeof(T)+sizeof(U);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { return d.f(); }
+};
+
+template<template<class> class D,class E> int f(D<E> &d1)
+{
+ d1.f();
+ C<D,E> d2;
+ d2.f();
+ return 0;
+}
+
+int main()
+{
+ D<int> c1;
+ D<char> c2;
+ f(c1);
+ f(c2);
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f() const;
+};
+
+template<class T> int D<T>::f() const
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() const { return d.f(); }
+};
+
+template<template<class> class D,class E> int f(const D<E> &d1)
+{
+ d1.f();
+ C<D,E> d2;
+ d2.f();
+ return 0;
+}
+
+int main()
+{
+ D<const int> c1;
+ D<char> c2;
+ const D<char> c3(c2);
+ f(c1);
+ f(c2);
+ f(c3);
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { return d.f(); }
+};
+
+template<template<class> class D,class E> int f(D<E> &d1)
+{
+ d1.f();
+ C<D,E> d2;
+ d2.f();
+ return 0;
+}
+
+template<> int f<>(D<char> &d1)
+{
+ d1.f();
+ return 0;
+}
+
+int main()
+{
+ D<int> c1;
+ D<char> c2;
+ f(c1);
+ f(c2);
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+extern "C" void abort();
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { abort(); return 0; }
+};
+
+template<class E> class C<D,E>
+{
+ D<E> d;
+ public:
+ int f() { return d.f(); }
+};
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+// Build don't link:
+
+template<class E,class F> class D
+{
+};
+
+template<template<class> class D,class E> class C
+{ // ERROR - ref below
+};
+
+int main()
+{
+ C<D,int> c; // ERROR - param list not match
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+extern "C" void abort();
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { abort(); return 0; }
+};
+
+template<class E> class C<D,E>
+{
+ D<E> d;
+ public:
+ int f();
+};
+
+template<class E> int C<D,E>::f()
+{
+ return d.f();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+extern "C" void abort();
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { abort(); return 0; }
+};
+
+template<template <class> class F> class C<F,int>
+{
+ F<int> d;
+ public:
+ int f() { return d.f(); }
+};
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+extern "C" void abort();
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { abort(); return 0; }
+};
+
+template<template <class> class F> class C<F,int>
+{
+ F<int> d;
+ public:
+ int f();
+};
+
+template<template<class>class F> int C<F,int>::f()
+{
+ return d.f();
+}
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ template<template<class> class F> int f(F<int>);
+};
+
+template<template<class> class D,class E>
+template<template<class> class F> int C<D,E>::f(F<int>)
+{
+ F<E> d2;
+ return d2.f();
+}
+
+int main()
+{
+ C<D,int> c;
+ D<int> d;
+ c.f(d);
+}
--- /dev/null
+template<class T> class D
+{
+ public:
+ int f();
+};
+
+template<class T> int D<T>::f()
+{
+ return sizeof(T);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f();
+};
+
+template<template<class> class D,class E> int C<D,E>::f()
+{
+ D<E> d2;
+ return d2.f();
+}
+
+template class C<D,int>;
+
+int main()
+{
+ C<D,int> c;
+ c.f();
+}
--- /dev/null
+template<int T, class U = int> class D
+{
+ public:
+ int f();
+};
+
+template<int T, class U> int D<T,U>::f()
+{
+ return T+sizeof(U);
+}
+
+template<template<int> class D,class E> class C
+{
+ D<1> d;
+ public:
+ int f() { return d.f(); }
+};
+
+template<template<int> class D> int f(D<2> &d1)
+{
+ d1.f();
+ return 0;
+}
+
+template<template<int> class D> int f(D<1> &d1)
+{
+ d1.f();
+ return 0;
+}
+
+int main()
+{
+ D<1> c1;
+ f(c1);
+}
--- /dev/null
+template<int T, class U = int> class D
+{
+ public:
+ int f();
+};
+
+template<int T, class U> int D<T,U>::f()
+{
+ return T+sizeof(U);
+}
+
+template<template<int> class D,class E> class C
+{
+ D<1> d;
+ public:
+ int f() { return d.f(); }
+};
+
+template<template<int> class D> int f(D<1> &d1)
+{
+ d1.f();
+ return 0;
+}
+
+int main()
+{
+ D<1> c1;
+ f(c1);
+}
--- /dev/null
+template<int T, class U = int> class D
+{
+ public:
+ int f();
+};
+
+template<int T, class U> int D<T,U>::f()
+{
+ return T+sizeof(U);
+}
+
+template<template<int> class D,class E> class C
+{
+ D<1> d;
+ public:
+ int f() { return d.f(); }
+};
+
+template<template<int> class D, int T> int f(D<T> &d1)
+{
+ d1.f();
+ return T;
+}
+
+int main()
+{
+ D<1> c1;
+ f(c1);
+}
--- /dev/null
+template<class T, class U = int> class D
+{
+ public:
+ int f();
+};
+
+template<class T, class U> int D<T,U>::f()
+{
+ return sizeof(T)+sizeof(U);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { return d.f(); }
+};
+
+template<template<class> class D> int f(D<int> &d1)
+{
+ d1.f();
+ return 0;
+}
+
+int main()
+{
+ D<int> c1;
+ f(c1);
+}
--- /dev/null
+template<class T, class U = T> class D
+{
+ public:
+ int f();
+};
+
+template<class T, class U> int D<T,U>::f()
+{
+ return sizeof(T)+sizeof(U);
+}
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+ public:
+ int f() { return d.f(); }
+};
+
+template<template<class> class D> int f(D<int> &d1)
+{
+ d1.f();
+ return 0;
+}
+
+int main()
+{
+ D<int> c1;
+ f(c1);
+}
--- /dev/null
+// Build don't link:
+
+template<class E> class D
+{
+};
+
+template<template<class> class D,class E> class C
+{
+ D<1> d; // ERROR - arg not match
+};
+
+int main()
+{
+ C<D,int> c;
+}
--- /dev/null
+// Build don't link:
+
+template<int> class D
+{
+};
+
+template<template<int> class D,class E> class C
+{
+ D<int> d; // ERROR - arg not match
+};
+
+int main()
+{
+ C<D,int> c;
+}
--- /dev/null
+template<int> class F
+{
+};
+
+template<template<int> class D,class E> class C
+{
+ D<1> d;
+};
+
+int main()
+{
+ C<F,int> c;
+}
--- /dev/null
+// Build don't link:
+
+template<class E> class D
+{
+};
+
+template<template<class> class D,class E> class C // ERROR - ref below
+{
+ D<int,int> d; // ERROR - arg not match
+};
+
+int main()
+{
+ C<D,int> c;
+}
--- /dev/null
+template<class E> class DD
+{
+};
+
+template<int> class D
+{
+};
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+};
+
+int main()
+{
+ C<DD,int> c;
+}
--- /dev/null
+template<class E,class F=int> class D
+{
+};
+
+template<template<class> class D,class E> class C
+{
+ D<E> d;
+};
+
+int main()
+{
+ C<D,int> c;
+}