p18.cpp 1.4 KB

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