Douglas Gregor | de650ae | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | template<template<typename T> class MetaFun, typename Value> |
| 4 | struct apply { |
| 5 | typedef typename MetaFun<Value>::type type; |
| 6 | }; |
| 7 | |
| 8 | template<class T> |
| 9 | struct add_pointer { |
| 10 | typedef T* type; |
| 11 | }; |
| 12 | |
| 13 | template<class T> |
| 14 | struct add_reference { |
| 15 | typedef T& type; |
| 16 | }; |
| 17 | |
| 18 | int i; |
| 19 | apply<add_pointer, int>::type ip = &i; |
| 20 | apply<add_reference, int>::type ir = i; |
| 21 | apply<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 Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 22 | |
| 23 | // Template template parameters |
| 24 | template<int> struct B; // expected-note{{has a different type 'int'}} |
| 25 | |
| 26 | template<typename T, |
| 27 | template<T Value> class X> // expected-error{{cannot have type 'float'}} \ |
| 28 | // expected-note{{with type 'long'}} |
| 29 | struct X0 { }; |
| 30 | |
| 31 | X0<int, B> x0b1; |
| 32 | X0<float, B> x0b2; // expected-note{{while substituting}} |
| 33 | X0<long, B> x0b3; // expected-error{{template template argument has different template parameters}} |