This repository groups several projects implemented in modern C++ (C++23) for practicing object-oriented programming, genericity, data structures and algorithms, error handling, concurrency, and testing best practices.
A console-based Minesweeper game.
- Features:
- Random grid generation with mines.
- Cell revealing (with recursive or iterative cascade).
- Flag marking.
- Win/loss detection.
- Key concepts:
- OOP, classes, inheritance, polymorphism.
- Use of
std::unique_ptr,std::vector. - RAII,
std::move,std::random.
- Compilation: see instructions below.
A complete Sudoku program:
- Solver: solves any partial grid via backtracking.
- Puzzle generator: creates a random grid with a unique solution (up to ~50 empty cells).
- Player mode: value input, solution verification, colors.
- Key concepts:
- Recursive backtracking.
- State management, grid copy/restoration.
- Validation algorithms (rows, columns, blocks).
std::shuffle, random generation.- ANSI sequences for colored output, natively enabled on Linux/macOS and via the Windows Virtual Terminal API on
Windows, with conditional code (
#ifdef _WIN32) for true cross‑platform compilation.
- Compilation: see instructions below.
A generic dynamic container and a dynamic bitset.
- Goals:
- Implement a
MiniVector<T>similar tostd::vector(dynamic allocation, rule of 5, simple iterators). - Build a
DynamicBitsetbased onMiniVector<unsigned char>with binary operations (set,reset,test,flip).
- Implement a
- Key concepts:
- Class templates.
- Memory management (
std::unique_ptr). - Operator overloading.
- Bitwise operations.
- Status: under development.
A generic BST (Binary Search Tree) with insertion, search, deletion, and traversals.
- Planned features:
BinarySearchTree<T>parameterised by type.- In‑order, pre‑order, post‑order traversals.
- Simple iterators.
- Use of
std::unique_ptrfor node management.
- Key concepts:
- Class and function templates.
- Recursion.
- Smart pointers.
- Customisable comparators.
- Status: to be started.
A parser and evaluator for mathematical expressions in infix notation (e.g., "3 + 4 * (2 - 1)" → 7).
- Planned features:
- Lexical analysis: tokenise a string into tokens (numbers, operators, parentheses).
- Recursive‑descent parser respecting operator precedence (
*//before+/-) and parentheses. - Construction of an Abstract Syntax Tree (AST) representing the expression.
- Recursive evaluation of the AST.
- Error handling: invalid syntax, division by zero, mismatched parentheses.
- Key concepts:
- Recursion and syntax trees.
- Separation of lexer / parser / evaluator.
enum classfor token types.- Proper error handling (exceptions, or
std::optional/std::expected).
- Status: to be started.
A minimal JSON parser and an API for manipulating JSON data.
- Planned features:
- Lexical and syntactic analysis of a JSON file.
- Building a tree of values (
JsonValue). - Field access, iteration over arrays.
- Serialisation (back to JSON text).
- Key concepts:
- Variadic templates.
std::variant,std::optional,std::vector,std::map.- Recursion over structures.
- Type traits and SFINAE.
- Status: to be started.
A simple thread pool and/or a producer‑consumer example.
- Planned features:
ThreadPool: task submission (std::function,std::future), thread‑safe queue.- Producer‑consumer example with multiple producer and consumer threads.
- Proper synchronisation (no race conditions, no deadlocks).
- Key concepts:
std::thread,std::mutex,std::lock_guard,std::unique_lock.std::condition_variable,std::atomic.std::future/std::promise.- Race conditions, deadlocks, and how to avoid them.
- Status: to be started.
Goal: replace manual validation (compile + run + visual check) with a versioned, reproducible, and continuously executable test suite.
- Framework: Catch2 (header‑only, lightweight, good CMake integration) — to be confirmed against GoogleTest depending on needs.
- Initial scope (already completed projects, tests added retroactively):
- Minesweeper: mine placement, neighbour mine count, cascade reveal, win/loss detection.
- Sudoku: row/column/block validation, backtracking solve, uniqueness of generated solution, consistency of
generatePuzzle(number of holes, state restoration).
- Future scope: every new project (MiniVector, DynamicBitset, BST, expression evaluator, JSON, concurrency) is delivered with its own test suite from the start, rather than added afterwards.
- Status: to be integrated.
- C++23 compiler: GCC ≥ 14 (for
<print>support). This is the only compiler verified by CI (Linux, macOS via Homebrew, Windows via MinGW-w64/MSYS2). Clang and MSVC are not currently tested and are not guaranteed to work - CMake ≥ 3.20 (recommended) or a simple Makefile.
- Operating system: Windows 10/11, Linux, macOS.
- For coloured output on Windows, the program automatically enables virtual terminal mode; on Linux/macOS, ANSI codes work natively.
- For the concurrency project, a properly linked threads library (
-lpthreadon Linux/macOS depending on compiler; usually automatic with CMake viaThreads::Threads). - For automated tests, Catch2 (retrievable via CMake
FetchContent, or a package manager like vcpkg / Conan).
Don't forget to pull the submodules with the repository using --recursive:
git clone --recursive https://github.com/SamuelDouay/language_cpp.gitor if you have already cloned the repository:
git submodule init
git submodule updateTo build the project you will need a C++23 compliant compiler.
Each project is independent and has its own folder.
# At the root of the repository
cmake -S . -B build
cmake --build build
# Run a project (e.g., Sudoku)
./build/sudoku
# Run the test suite (once Catch2 is integrated)
ctest --test-dir buildcd sudoku
g++ -std=c++23 -Wall -Wextra -O2 src/*.cpp -o sudoku
./sudoku