Skip to content

Commit

Permalink
ipucu 9 eklendi
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetveburak committed Aug 25, 2021
1 parent b6b49b4 commit 0d951f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@
- [C++20 ipuçları 006](cpp-ipuclari.md#c20-ipuçları-006)
- [C++20 ipuçları 007](cpp-ipuclari.md#c20-ipuçları-007)
- [C++20 ipuçları 008](cpp-ipuclari.md#c20-ipuçları-008)
- [C++20 ipuçları 009](cpp-ipuclari.md#c20-ipuçları-009)


16 changes: 16 additions & 0 deletions cpp-ipuclari.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [C++20 ipuçları 006](#c20-ipuçları-006)
- [C++20 ipuçları 007](#c20-ipuçları-007)
- [C++20 ipuçları 008](#c20-ipuçları-008)
- [C++20 ipuçları 009](#c20-ipuçları-009)


### [C++20 ipuçları 001](https://t.me/trcpp/9585)
Expand Down Expand Up @@ -178,4 +179,19 @@ int main() {
A y = {.d = 1.5, .str = "mustafa"}; // 0, 1.5, "mustafa"
A z = {.d = 4.4, .x = 5}; // gecersiz. x'e d'den once ilk deger verilmeli
}
```
### [C++20 ipuçları 009](https://t.me/trcpp/11337)
C++17'de yapısal bağlama *(structured binding)* ile tanımlanmış değişkenler *lambda* ifadelerinde doğrudan yakalanamıyordu *(capture)*. Böyle değişkenleri yakalamak için "generalized lambda capture" ("lambda init capture" da deniliyor) kullanmak zorundaydık. C++20'de bu kısıtlama ortadan kalktı.
```cpp
#include <utility>
std::pair<int, int> foo();
int main() {
auto [x, y] = foo();
auto f = [x]() { return x + 5; }; // C++17'de gecersiz C++20'de gecerli
auto g = [x = x]() { return x + 5; }; // C++17'de gecerli
}
```

0 comments on commit 0d951f5

Please sign in to comment.