-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy path265.md
52 lines (37 loc) · 1.16 KB
/
265.md
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
<details open><summary>Info</summary><p>
* **Did you know that C++23 added Attributes on Lambda-Expressions?**
* https://wg21.link/P2173
</p></details><details open><summary>Example</summary><p>
```cpp
constexpr auto foo = [] [[deprecated]] { };
int main() {
foo(); // operator() is deprecated
}
```
> https://godbolt.org/z/MaeTnG9eb
</p></details><details open><summary>Puzzle</summary><p>
* **Can you implement variable template lambda expression `foo` which is marked nodiscard for integral types?**
```cpp
//TODO foo
int main() {
using namespace boost::ut;
"should be callable for non integral types"_test = [] {
foo<float>();
foo<double>();
};
"should verify the result for integral types"_test = [] {
expect(0_c == foo<char>());
expect(not foo<bool>());
expect(0_s == foo<short>());
expect(0_i == foo<int>());
};
"should ignore the result for integral types"_test = [] {
/*TODO*/ foo<char>();
/*TODO*/ foo<bool>();
/*TODO*/ foo<short>();
/*TODO*/ foo<int>();
};
}
```
> https://godbolt.org/z/fKfjsbWoh
</p></details><details><summary>Solutions</summary><p>