-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathtest.cpp
More file actions
54 lines (42 loc) · 1.15 KB
/
test.cpp
File metadata and controls
54 lines (42 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
struct A {
int a;
int &b;
int &geta() & { return a; } // COMPLIANT
int const &geta2() const & { // COMPLIANT -- due to overload below
return a;
}
int geta2() && { return a; }
int const &getabad() const & { // NON_COMPLIANT -- no overload provided
return a;
}
int getb() && { return b; } // COMPLIANT -- b is not a subobject
A const *getstruct() const & { // COMPLIANT -- due to overload below
return this;
}
A getstruct() const && = delete;
A const *getstructbad() const & { // NON_COMPLIANT -- no overload provided
return this;
}
A &getstructbad2() { return *this; } // NON_COMPLIANT
};
class C {
C *f() { // COMPLIANT -- this is not explicitly designated therefore this is
// not
// relevant for this rule
C *thisclass = this;
return thisclass;
}
};
struct Templ {
template <typename T>
Templ const *f(T) const & { // NON_COMPLIANT -- for an instantiation below
return this;
}
void f(int) const && = delete;
};
void f(int p, float p1) {
Templ t;
t.f(p);
t.f(p1); // instantiation that causes issue due to parameter list type meaning
// there is no overload
}