gcc-statement-expression Questions

2

Solved

I just read code like this: auto value = ({ auto it = container.find(key); it != container.end() ? it->second : default_value; }); What is this ({}) called? I don't think I've ever seen this ...
Northcliffe asked 12/8, 2023 at 19:38

1

Solved

#include <stdio.h> int main() { int sum = 0, result = (({for (int i = 0; i < 5; i++) sum += i;}), sum); printf("result = %d\n", result); return 0; } displays result = 10 ...
Quicklime asked 9/8, 2023 at 10:26

4

Solved

I came across this weird C++ program. #include <iostream> using namespace std; int main() { int a = ({int x; cin >> x; x;}); cout << a; } Can anyone explain what is going on?...
1

© 2022 - 2024 — McMap. All rights reserved.