blob: 6035308b0a9f0823a995b322061cbc95e09d8638 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregorde650ae2009-03-31 18:38:02 +00002template<template<typename T> class MetaFun, typename Value>
3struct apply {
4 typedef typename MetaFun<Value>::type type;
5};
6
7template<class T>
8struct add_pointer {
9 typedef T* type;
10};
11
12template<class T>
13struct add_reference {
14 typedef T& type;
15};
16
17int i;
18apply<add_pointer, int>::type ip = &i;
19apply<add_reference, int>::type ir = i;
20apply<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot be initialized with a value of type 'int'}}
Douglas Gregor9148c3f2009-11-11 19:13:48 +000021
22// Template template parameters
23template<int> struct B; // expected-note{{has a different type 'int'}}
24
25template<typename T,
26 template<T Value> class X> // expected-error{{cannot have type 'float'}} \
27 // expected-note{{with type 'long'}}
28struct X0 { };
29
30X0<int, B> x0b1;
31X0<float, B> x0b2; // expected-note{{while substituting}}
32X0<long, B> x0b3; // expected-error{{template template argument has different template parameters}}
Douglas Gregorfb898e12009-11-12 16:20:59 +000033
34template<template<int V> class TT> // expected-note{{parameter with type 'int'}}
35struct X1 { };
36
37template<typename T, template<T V> class TT>
38struct X2 {
39 X1<TT> x1; // expected-error{{has different template parameters}}
40};
41
42template<int V> struct X3i { };
43template<long V> struct X3l { }; // expected-note{{different type 'long'}}
44
45X2<int, X3i> x2okay;
46X2<long, X3l> x2bad; // expected-note{{instantiation}}