std::byte
for "plain byte data" instead ofchar
,unsigned char
oruint8_t
- use
std::optional<T>
for optional return values (kinda obvious, but you have to know) std::variant<T1,T2,...>
is a C++ version ofunion
- use
std::bitset<N>
for bitfields - structured bindings are useful for multiple return values:
std::tuple<std::string, int>> get_name_and_age(); auto [ name, age ] = get_name_and_age();
- template parameters can be "const T" which creates read-only fields even if the type itself is non-const:
std::pair<const int, int> pair { 1 , 2 }; pair.first = 10; // not allowed pair.second = 20; // allowed
#include <filesystem>
provides directory and file information
Last active
December 8, 2018 14:26
-
-
Save ikskuh/d5ff4cacba34380971cea841da80cf7f to your computer and use it in GitHub Desktop.
C++ Cheat Sheet & Brain Markers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment