Douglas Gregor | 81495f3 | 2012-02-12 18:42:33 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -std=c++11 %s -Wunused -verify |
| 2 | |
| 3 | template<typename T, typename U> |
| 4 | struct is_same { |
| 5 | static const bool value = false; |
| 6 | }; |
| 7 | |
| 8 | template<typename T> |
| 9 | struct is_same<T, T> { |
| 10 | static const bool value = true; |
| 11 | }; |
| 12 | |
| 13 | void f3() { |
| 14 | float x, &r = x; |
| 15 | int i; |
| 16 | int &ir = i; |
| 17 | const int &irc = i; |
| 18 | |
| 19 | [=,&irc,&ir] { |
| 20 | static_assert(is_same<decltype(x), float>::value, "should be float"); |
| 21 | static_assert(is_same<decltype((x)), const float&>::value, |
| 22 | "should be const float&"); |
| 23 | static_assert(is_same<decltype(r), float&>::value, "should be float&"); |
| 24 | static_assert(is_same<decltype(((r))), float const&>::value, |
| 25 | "should be const float&"); |
| 26 | static_assert(is_same<decltype(ir), int&>::value, "should be int&"); |
| 27 | static_assert(is_same<decltype((ir)), int&>::value, "should be int&"); |
| 28 | static_assert(is_same<decltype(irc), const int&>::value, |
| 29 | "should be const int&"); |
| 30 | static_assert(is_same<decltype((irc)), const int&>::value, |
| 31 | "should be const int&"); |
| 32 | }(); |
| 33 | |
| 34 | [=] { |
| 35 | [=] () mutable { |
| 36 | static_assert(is_same<decltype(x), float>::value, "should be float"); |
| 37 | static_assert(is_same<decltype((x)), const float&>::value, |
| 38 | "should be const float&"); |
| 39 | }(); |
| 40 | }(); |
| 41 | } |