Clang Project

clang_source_code/test/SemaCXX/cxx2a-lambda-default-ctor-assign.cpp
1// RUN: %clang_cc1 -std=c++2a -verify %s
2
3auto a = []{};
4decltype(a) a2;
5void f(decltype(a) x, decltype(a) y) {
6  x = y;
7  x = static_cast<decltype(a)&&>(y);
8}
9
10template<typename T>
11struct X {
12  constexpr X() { T::error; } // expected-error {{'::'}}
13  X(const X&);
14  constexpr X &operator=(const X&) { T::error; } // expected-error {{'::'}}
15  constexpr X &operator=(X&&) { T::error; } // expected-error {{'::'}}
16};
17extern X<int> x;
18auto b = [x = x]{}; // expected-note 3{{in instantiation of}}
19decltype(b) b2; // expected-note {{in implicit default constructor}}
20void f(decltype(b) x, decltype(b) y) {
21  x = y; // expected-note {{in implicit copy assignment}}
22  x = static_cast<decltype(b)&&>(y); // expected-note {{in implicit move assignment}}
23}
24
25struct Y {
26  Y() = delete; // expected-note {{deleted}}
27  Y(const Y&);
28  Y &operator=(const Y&) = delete; // expected-note 2{{deleted}}
29  Y &operator=(Y&&) = delete;
30};
31extern Y y;
32auto c = [y = y]{}; // expected-note 3{{deleted because}}
33decltype(c) c2; // expected-error {{deleted}}
34void f(decltype(c) x, decltype(c) y) {
35  x = y; // expected-error {{deleted}}
36  x = static_cast<decltype(c)&&>(y); // expected-error {{deleted}}
37}
38