cxx2a-lambda-default-ctor-assign.cpp 818 B

12345678910111213141516171819202122
  1. // RUN: %clang_cc1 -std=c++2a -verify %s
  2. void no_capture() {
  3. auto x = [] {};
  4. decltype(x) y;
  5. x = x;
  6. x = static_cast<decltype(x)&&>(x);
  7. }
  8. void capture_default(int i) {
  9. auto x = [=] {}; // expected-note 2{{candidate constructor}} expected-note 2{{lambda expression begins here}}
  10. decltype(x) y; // expected-error {{no matching constructor}}
  11. x = x; // expected-error {{cannot be assigned}}
  12. x = static_cast<decltype(x)&&>(x); // expected-error {{cannot be assigned}}
  13. }
  14. void explicit_capture(int i) {
  15. auto x = [i] {}; // expected-note 2{{candidate constructor}} expected-note 2{{lambda expression begins here}}
  16. decltype(x) y; // expected-error {{no matching constructor}}
  17. x = x; // expected-error {{cannot be assigned}}
  18. x = static_cast<decltype(x)&&>(x); // expected-error {{cannot be assigned}}
  19. }