blob: 930a4b32fa06cd128e7499463b8375b5468fe9d4 [file] [log] [blame]
Douglas Gregor81495f32012-02-12 18:42:33 +00001// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
2
3template<typename T, typename U>
4struct is_same {
5 static const bool value = false;
6};
7
8template<typename T>
9struct is_same<T, T> {
10 static const bool value = true;
11};
12
13void f3() {
14 float x, &r = x;
15 int i;
16 int &ir = i;
17 const int &irc = i;
18
19 [=,&irc,&ir] {
Douglas Gregor812d8f62012-02-18 05:51:20 +000020 static_assert(is_same<decltype(((r))), float const&>::value,
21 "should be const float&");
Douglas Gregor81495f32012-02-12 18:42:33 +000022 static_assert(is_same<decltype(x), float>::value, "should be float");
23 static_assert(is_same<decltype((x)), const float&>::value,
24 "should be const float&");
25 static_assert(is_same<decltype(r), float&>::value, "should be float&");
Douglas Gregor81495f32012-02-12 18:42:33 +000026 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");
Douglas Gregorfdf598e2012-02-18 09:37:24 +000037 static_assert(is_same<decltype((x)), float&>::value,
38 "should be float&");
Douglas Gregor81495f32012-02-12 18:42:33 +000039 }();
40 }();
Douglas Gregor7ae3c752012-02-17 04:02:59 +000041
42 [&i] {
43 static_assert(is_same<decltype((i)), int&>::value, "should be int&");
44 }();
Douglas Gregor81495f32012-02-12 18:42:33 +000045}