C++ quick reference
Everyday syntax and functions on one page.
| Code | Purpose |
|---|---|
auto x = 5; | Let the compiler work out the type |
for (auto &x : v) | Loop by reference, so edits stick |
const T& | Pass large objects cheaply and safely |
sort(v.begin(), v.end()) | Sort a vector |
find(a, b, x) | Search a range |
to_string(n) / stoi(s) | Number to string and back |
make_unique<T>() | Create an owned heap object |
ios::sync_with_stdio(false) | Speed up cin and cout in contests |