Interactive Course & Complete Documentation
g++ -std=c++20 -Wall -Wextra -Wpedantic -Wconversion -fsanitize=address,undefined -O2 main.cpp -o app
Enables standard C++20, all warnings, strict pedantic checks, address & undefined behavior sanitizers, and optimization level 2.
| Container | Random Access | Insert / Erase (Back) | Insert / Erase (Front/Middle) | Underlying Structure |
|---|---|---|---|---|
std::vector |
O(1) | O(1) amortized | O(N) | Contiguous Heap Array |
std::deque |
O(1) | O(1) | O(1) front/back, O(N) middle | Chunked memory blocks |
std::list |
O(N) | O(1) | O(1) if iterator known | Doubly-linked list |
std::map / std::set |
O(log N) search | O(log N) | O(log N) | Red-Black Tree (Ordered) |
std::unordered_map |
O(1) avg search | O(1) avg | O(1) avg | Hash Table |
std::unique_ptr by default. Only use std::shared_ptr when ownership is genuinely shared.const Type& or std::string_view to eliminate copies.std::jthread over std::thread: Auto-joins on destruction and cleanly handles cooperative cancellation via std::stop_token.std::scoped_lock(mtxA, mtxB) when locking multiple mutexes simultaneously.cv.wait(lock) without a predicate lambda loop: cv.wait(lock, [&]{ return !queue.empty(); });.alignas(64).std::async(std::launch::async, ...) and std::future for concurrent calculations with automatic exception propagation.