Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 1734317 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 2 | |
| 3 | template<typename MetaFun, typename T> |
| 4 | struct bind_metafun { |
| 5 | typedef typename MetaFun::template apply<T> type; |
| 6 | }; |
| 7 | |
| 8 | struct add_pointer { |
| 9 | template<typename T> |
| 10 | struct apply { |
| 11 | typedef T* type; |
| 12 | }; |
| 13 | }; |
| 14 | |
| 15 | int i; |
| 16 | // FIXME: if we make the declarator below a pointer (e.g., with *ip), |
| 17 | // the error message isn't so good because we don't get the handy |
| 18 | // 'aka' telling us that we're dealing with an int**. Should we fix |
| 19 | // getDesugaredType to dig through pointers and such? |
| 20 | bind_metafun<add_pointer, int>::type::type ip = &i; |
Eli Friedman | a91eb54 | 2009-12-22 02:10:53 +0000 | [diff] [blame] | 21 | bind_metafun<add_pointer, float>::type::type fp = &i; // expected-error{{cannot initialize a variable of type 'bind_metafun<add_pointer, float>::type::type' (aka 'float *') with an rvalue of type 'int *'}} |
Douglas Gregor | 1734317 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | template<typename T> |
| 25 | struct extract_type_type { |
| 26 | typedef typename T::type::type t; |
| 27 | }; |
| 28 | |
| 29 | double d; |
| 30 | extract_type_type<bind_metafun<add_pointer, double> >::t dp = &d; |