std::move
1. Transfers ownership of an object to another location, leaving the original empty. It prevents expensive or impossible copies by moving the underlying data instead. std::error_code
std::error_code is a lightweight C++ object for holding an error without throwing an exception. std::make_unique
You get back a std::unique_ptr<ClassName> that automatically deletes the object when it goes out of scope. <ClassName> — the type you want to allocate <arg1, arg2, ...> — the arguments forwarded to its constructor (can be zero or more) Note: Scope is defined as where it was originally declared. std::memory_order_acquire
memory_order_acquire is a constant within the memory_order enum. When a thread loads an atomic value with acquire, it is guaranteed to see all writes that the other thread made before its corresponding release store. std::exception
std::exception is the base class for all standard C++ exceptions, caught using a const reference. Give me one sentence on the method what std::nullopt
|
std::unique_ptr
Declares a pointer of a certain type. It starts as a null pointer. std::lock_gaurd
A wrapper that takes a mutexInstance and ensures that is is locked and automatically unlocked when it goes out of scope. std:string
Make a string object that is dynamic and has methods associated with it. This is different than a primitive string. std::optional<T>
A wrapper that holds either a value of type T or nothing (std::nullopt). Use it as a return type when a function might produce no result, instead of returning a sentinel like -1 or nullptr. std::thread
std::queue
Creates a queue data structure for holding information std::unique_lock
std::getenv
Reads the value of an environment variable by name. Returns a const char* to the value string, or nullptr if the variable doesn't exist. Always check for nullptr before using the result to avoid crashes. |
std::memory_order_relaxed
A value of a enum that signals that the compiler and CPU that it is allowed to reorder an operation relative to when the code was written in the most optimized way it thinks it should. std::memory_order_released
This is an memory_order enum flag that is used to suggest an atomic object can only perform an operation if every line above it has already ran. std:condition_variable
This will force the thread to sleep that was holding a unique lock. It is only woken up once .notify_all() or .notify_one() is called. These commands wake up the lock and check the conditional in wait(). If it evaluates to true it will proceed. If false, it will go back to sleep. std::mutex
This creates a mutexInstance. Has the ability to create a lock and unlock mechanism over processes. This prevents certain processes from happening simultaneously more than once. std::atomic
std::atomic<T> wraps any type T and guarantees that reading and writing to it from multiple threads is always safe. Without it, two threads touching the same variable simultaneously is undefined behaviour in C++. It essentially puts a protection around the variable so every read and write is always a clean, complete operation. std::ofstream
Opens a file for writing, creating it if it doesn't exist. Writing to it works just like std::cout using the << operator. The file is automatically closed when the object goes out of scope. |
Cheatography
https://cheatography.com
C++ Std Library Cheat Sheet (DRAFT) by blakecromar
A cheet sheet on the C++ std library
This is a draft cheat sheet. It is a work in progress and is not finished yet.