Skip to content

Latest commit

Β 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AModernCppPlayground πŸ—οΈ

CI Docs C++ License

πŸ“– Documentation: https://gauravagarwalgarg.github.io/modern-cpp-playground/

πŸ“¦ Repository: GitHub

Production-quality Modern C++ learning & interview preparation repository for HFT, HPC, GPU, Systems, Networking, OS, Embedded, and Low-Latency engineering roles.


Who This Is For

Starting fresh with C++? See the Learning Path below and the C++ Standards Evolution doc.

Preparing for interviews? Every file is self-contained, compilable, and annotated with interview relevance and day-to-day usage context.

Candidates preparing for:

  • C++ Software Engineer roles at FAANG, trading firms, GPU companies
  • Low-Latency / HFT roles (Citadel, Jump, Two Sigma, Jane Street, Optiver)
  • High-Performance Computing roles (HPC clusters, scientific computing)
  • GPU / Infrastructure roles (NVIDIA, AMD, graphics engines)
  • Systems / Networking roles (kernel, drivers, protocols)
  • Embedded C++ roles (automotive, IoT, RTOS)
  • OS and Concurrency roles (scheduler, lock-free, memory model)

Repository Structure

AModernCppPlayground/
β”œβ”€β”€ CMakeLists.txt                    # Root CMake build (auto-discovers all src/*.cpp)
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ modern_cpp/                   # C++11/14/17/20 language features
β”‚   β”‚   β”œβ”€β”€ move_semantics.cpp
β”‚   β”‚   β”œβ”€β”€ smart_pointers.cpp
β”‚   β”‚   β”œβ”€β”€ templates_sfinae.cpp
β”‚   β”‚   β”œβ”€β”€ concepts.cpp
β”‚   β”‚   β”œβ”€β”€ constexpr_consteval.cpp
β”‚   β”‚   β”œβ”€β”€ lambdas.cpp
β”‚   β”‚   β”œβ”€β”€ raii.cpp
β”‚   β”‚   β”œβ”€β”€ rule_of_five.cpp
β”‚   β”‚   β”œβ”€β”€ optional_variant_any.cpp
β”‚   β”‚   β”œβ”€β”€ structured_bindings.cpp
β”‚   β”‚   β”œβ”€β”€ ranges.cpp
β”‚   β”‚   β”œβ”€β”€ crtp.cpp
β”‚   β”‚   β”œβ”€β”€ perfect_forwarding.cpp
β”‚   β”‚   β”œβ”€β”€ custom_allocator.cpp
β”‚   β”‚   β”œβ”€β”€ copy_elision.cpp
β”‚   β”‚   β”œβ”€β”€ noexcept.cpp
β”‚   β”‚   └── practical/               # Day-to-day modern C++ patterns
β”‚   β”‚       β”œβ”€β”€ value_semantics.cpp       # Regular types, spaceship operator
β”‚   β”‚       β”œβ”€β”€ compile_time_programming.cpp # constexpr, consteval, if constexpr
β”‚   β”‚       β”œβ”€β”€ raii_patterns.cpp         # ScopeGuard, TimerGuard, C API wrappers
β”‚   β”‚       β”œβ”€β”€ error_handling.cpp        # Result<T,E>, monadic chaining, optional
β”‚   β”‚       └── type_traits_concepts.cpp  # Custom concepts, constrained templates
β”‚   β”‚
β”‚   β”œβ”€β”€ patterns/                     # Design Patterns
β”‚   β”‚   β”œβ”€β”€ singleton.cpp             # GoF: Meyer's singleton
β”‚   β”‚   β”œβ”€β”€ factory.cpp               # GoF: Factory method
β”‚   β”‚   β”œβ”€β”€ abstract_factory.cpp      # GoF: Abstract factory
β”‚   β”‚   β”œβ”€β”€ builder.cpp               # GoF: Builder
β”‚   β”‚   β”œβ”€β”€ observer.cpp              # GoF: Classic observer
β”‚   β”‚   β”œβ”€β”€ strategy.cpp              # GoF: Strategy
β”‚   β”‚   β”œβ”€β”€ command.cpp               # GoF: Command
β”‚   β”‚   β”œβ”€β”€ decorator.cpp             # GoF: Decorator
β”‚   β”‚   β”œβ”€β”€ adapter.cpp               # GoF: Adapter
β”‚   β”‚   β”œβ”€β”€ facade.cpp                # GoF: Facade
β”‚   β”‚   β”œβ”€β”€ template_method.cpp       # GoF: Template Method
β”‚   β”‚   β”œβ”€β”€ state.cpp                 # GoF: State
β”‚   β”‚   β”œβ”€β”€ visitor.cpp               # GoF: Visitor
β”‚   β”‚   β”œβ”€β”€ chain_of_responsibility.cpp
β”‚   β”‚   β”œβ”€β”€ proxy.cpp                 # GoF: Caching/Logging proxy
β”‚   β”‚   β”œβ”€β”€ composite.cpp             # GoF: File system tree
β”‚   β”‚   β”œβ”€β”€ flyweight.cpp             # GoF: Shared state optimization
β”‚   β”‚   β”œβ”€β”€ memento.cpp               # GoF: Undo/Redo history
β”‚   β”‚   β”œβ”€β”€ iterator.cpp              # GoF: Custom ring buffer iterator
β”‚   β”‚   β”œβ”€β”€ mediator.cpp              # GoF: Event bus
β”‚   β”‚   └── software_design/          # β˜… Modern C++ Design Patterns
β”‚   β”‚       β”œβ”€β”€ type_erasure.cpp          # The core pattern of modern C++
β”‚   β”‚       β”œβ”€β”€ external_polymorphism.cpp # Polymorphism without modifying types
β”‚   β”‚       β”œβ”€β”€ value_based_strategy.cpp  # std::function strategy injection
β”‚   β”‚       β”œβ”€β”€ pimpl_idiom.cpp           # Bridge/Pimpl for ABI stability
β”‚   β”‚       β”œβ”€β”€ strong_types.cpp          # CRTP mixin for type safety
β”‚   β”‚       β”œβ”€β”€ small_buffer_optimization.cpp # SBO type erasure (no heap)
β”‚   β”‚       β”œβ”€β”€ prototype_pattern.cpp     # Virtual clone() for deep copy
β”‚   β”‚       β”œβ”€β”€ modern_observer.cpp       # Signal/slot with RAII connections
β”‚   β”‚       β”œβ”€β”€ compile_time_decorator.cpp# Zero-overhead template decoration
β”‚   β”‚       └── runtime_decorator.cpp     # Type-erased composable decorators
β”‚   β”‚
β”‚   β”œβ”€β”€ concurrency/                  # Threading, atomics, lock-free
β”‚   β”‚   β”œβ”€β”€ threads_basics.cpp
β”‚   β”‚   β”œβ”€β”€ mutex_condvar.cpp
β”‚   β”‚   β”œβ”€β”€ atomics.cpp
β”‚   β”‚   β”œβ”€β”€ memory_model.cpp
β”‚   β”‚   β”œβ”€β”€ lock_free_queue.cpp
β”‚   β”‚   β”œβ”€β”€ thread_pool.cpp
β”‚   β”‚   └── producer_consumer.cpp
β”‚   β”‚
β”‚   β”œβ”€β”€ solid/                        # SOLID principles with code
β”‚   β”‚   └── solid_principles.cpp
β”‚   β”‚
β”‚   β”œβ”€β”€ systems/                      # Industry domain code
β”‚   β”‚   β”œβ”€β”€ hft/                      # HFT / Low-latency
β”‚   β”‚   β”‚   β”œβ”€β”€ order_book.cpp
β”‚   β”‚   β”‚   β”œβ”€β”€ market_data_handler.cpp
β”‚   β”‚   β”‚   └── matching_engine.cpp
β”‚   β”‚   β”œβ”€β”€ networking/               # Sockets, protocols
β”‚   β”‚   β”‚   β”œβ”€β”€ tcp_server.cpp
β”‚   β”‚   β”‚   └── epoll_server.cpp
β”‚   β”‚   β”œβ”€β”€ linux/                    # Linux programming
β”‚   β”‚   β”‚   β”œβ”€β”€ signal_handling.cpp
β”‚   β”‚   β”‚   └── mmap_shared_memory.cpp
β”‚   β”‚   β”œβ”€β”€ os/                       # OS concepts
β”‚   β”‚   β”‚   β”œβ”€β”€ virtual_memory.cpp
β”‚   β”‚   β”‚   └── scheduler_sim.cpp
β”‚   β”‚   β”œβ”€β”€ embedded/                 # Embedded C++
β”‚   β”‚   β”‚   └── state_machine.cpp
β”‚   β”‚   └── hpc_gpu/                  # HPC / GPU ecosystem
β”‚   β”‚       └── simd_vectorization.cpp
β”‚   β”‚
β”‚   β”œβ”€β”€ dsa/                          # DSA patterns in C++
β”‚   β”‚   β”œβ”€β”€ two_pointers.cpp
β”‚   β”‚   β”œβ”€β”€ sliding_window.cpp
β”‚   β”‚   β”œβ”€β”€ binary_search_on_answer.cpp
β”‚   β”‚   β”œβ”€β”€ monotonic_stack.cpp
β”‚   β”‚   β”œβ”€β”€ union_find.cpp
β”‚   β”‚   β”œβ”€β”€ trie.cpp
β”‚   β”‚   β”œβ”€β”€ segment_tree.cpp
β”‚   β”‚   β”œβ”€β”€ topological_sort.cpp
β”‚   β”‚   β”œβ”€β”€ bit_manipulation.cpp
β”‚   β”‚   β”œβ”€β”€ dijkstra.cpp              # Graph: shortest path
β”‚   β”‚   β”œβ”€β”€ kmp_string_matching.cpp   # Strings: pattern matching
β”‚   β”‚   β”œβ”€β”€ backtracking_nqueens.cpp  # Backtracking with pruning
β”‚   β”‚   β”œβ”€β”€ knapsack_01.cpp           # DP: 0/1 knapsack
β”‚   β”‚   β”œβ”€β”€ longest_common_subsequence.cpp  # DP: classic 2D
β”‚   β”‚   └── merge_sort.cpp            # Divide & conquer sort
β”‚   β”‚
β”‚   └── stl_like/                     # Custom STL implementations
β”‚       β”œβ”€β”€ doubly_linked_list.cpp
β”‚       β”œβ”€β”€ hash_map.cpp
β”‚       β”œβ”€β”€ lru_cache.cpp
β”‚       β”œβ”€β”€ memory_pool.cpp
β”‚       └── thread_safe_queue.cpp
β”‚
β”œβ”€β”€ docs/                             # Documentation
β”‚   β”œβ”€β”€ cpp-standards-evolution.md    # β˜… C++98 β†’ C++03 β†’ C++11 β†’ C++14 β†’ C++17 β†’ C++20 β†’ C++23 β†’ C++26
β”‚   β”œβ”€β”€ software-design-patterns.md   # β˜… Modern C++ design patterns (Iglberger)
β”‚   β”œβ”€β”€ modern-cpp.md                 # Quick reference: features & interview frequency
β”‚   β”œβ”€β”€ design-patterns.md            # GoF patterns in C++
β”‚   β”œβ”€β”€ solid-principles.md
β”‚   β”œβ”€β”€ hft-low-latency.md
β”‚   β”œβ”€β”€ networking.md
β”‚   β”œβ”€β”€ linux-programming.md
β”‚   β”œβ”€β”€ hpc-gpu.md
β”‚   β”œβ”€β”€ os-internals.md
β”‚   β”œβ”€β”€ embedded-cpp.md
β”‚   β”œβ”€β”€ dsa-patterns.md
β”‚   β”œβ”€β”€ concurrency.md
β”‚   └── interview-roadmap.md
β”‚
β”œβ”€β”€ tests/                            # Test programs
β”œβ”€β”€ benchmarks/                       # Performance benchmarks
└── scripts/                          # Build helpers

Build & Run

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)

# Run any example (executable name = path with / replaced by _)
./bin/modern_cpp_move_semantics
./bin/modern_cpp_practical_value_semantics
./bin/patterns_software_design_type_erasure
./bin/systems_hft_order_book
./bin/dsa_monotonic_stack
./bin/stl_like_lru_cache

Topic Coverage

Area Files Interview Priority
Modern C++ Features 16 + 5 practical β˜…β˜…β˜…β˜…β˜…
Software Design Patterns (NEW) 10 β˜…β˜…β˜…β˜…β˜…
Concurrency & Lock-Free 7 β˜…β˜…β˜…β˜…β˜…
GoF Design Patterns 20 β˜…β˜…β˜…β˜…β˜†
SOLID Principles 1 β˜…β˜…β˜…β˜…β˜†
HFT / Low-Latency 3 β˜…β˜…β˜…β˜…β˜…
Networking 2 β˜…β˜…β˜…β˜…β˜†
Linux Programming 2 β˜…β˜…β˜…β˜†β˜†
OS Internals 2 β˜…β˜…β˜…β˜†β˜†
Embedded 1 β˜…β˜…β˜…β˜†β˜†
HPC / GPU 1 β˜…β˜…β˜…β˜†β˜†
DSA Patterns 15 β˜…β˜…β˜…β˜…β˜…
Custom STL 5 β˜…β˜…β˜…β˜…β˜…

Learning Path

For Absolute Beginners

Start here if you're new to C++ or coming from another language:

πŸ“– Read: docs/cpp-standards-evolution.md (understand the timeline)
     ↓
1️⃣  src/modern_cpp/raii.cpp                    ← Foundation of C++ design
2️⃣  src/modern_cpp/smart_pointers.cpp          ← Memory management
3️⃣  src/modern_cpp/move_semantics.cpp          ← Efficiency
4️⃣  src/modern_cpp/lambdas.cpp                 ← Modern style
5️⃣  src/modern_cpp/practical/value_semantics.cpp ← How to think in C++
     ↓
πŸ“– Read: docs/modern-cpp.md (feature reference)
     ↓
6️⃣  src/modern_cpp/templates_sfinae.cpp        ← Generic programming
7️⃣  src/modern_cpp/concepts.cpp                ← Modern constraints
8️⃣  src/modern_cpp/practical/compile_time_programming.cpp
9️⃣  src/modern_cpp/practical/error_handling.cpp
πŸ”Ÿ  src/modern_cpp/practical/type_traits_concepts.cpp
     ↓
πŸ“– Read: docs/software-design-patterns.md
     ↓
1️⃣1️⃣ src/patterns/software_design/type_erasure.cpp       ← THE pattern
1️⃣2️⃣ src/patterns/software_design/external_polymorphism.cpp
1️⃣3️⃣ src/patterns/software_design/pimpl_idiom.cpp
1️⃣4️⃣ src/patterns/software_design/strong_types.cpp

For Experienced Developers (Interview Prep)

Focus on what interviewers actually ask:

Week 1 Week 2 Week 3
Move semantics Type erasure Lock-free queue
Smart pointers SBO optimization Thread pool
Perfect forwarding Pimpl idiom Memory model
Rule of Five Strong types Atomics
RAII patterns External polymorphism HFT systems

For HFT/Low-Latency Roles

Critical Path:
  move_semantics β†’ custom_allocator β†’ memory_pool β†’
  small_buffer_optimization β†’ lock_free_queue β†’
  order_book β†’ matching_engine β†’ simd_vectorization

Code Style

  • C++20 (builds with GCC 12+, Clang 14+, MSVC 19.30+)
  • Every file is self-contained with main() + assertions
  • Comments explain why, not just what
  • Each file header states: topic, interview relevance, day-to-day application
  • Complexity annotations on all functions
  • No raw new/delete unless demonstrating RAII contrast
  • Adapted code from external sources is attributed and re-styled for consistency

Reference Repos (Source Material)

The following repos were used as source material and adapted to fit this repository's structure and style:

Repo What we took Where it lives now
cpp_software_design (Iglberger) Type erasure, external polymorphism, SBO, strong types src/patterns/software_design/
design-patterns-cpp GoF pattern structure verification src/patterns/
C-Plus-Plus (algorithms) DSA reference implementations src/dsa/, src/stl_like/
cp-algorithms-aux Competitive programming algorithms Reference only

License

MIT

About

Modern C++17/20/23 code base: concurrency, patterns, systems

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages