• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
f3()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(((r))), float const&>::value,
21                   "should be const float&");
22     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&");
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)), float&>::value,
38                     "should be float&");
39     }();
40   }();
41 
42   [&i] {
43     static_assert(is_same<decltype((i)), int&>::value, "should be int&");
44   }();
45 }
46