// examples/cpp23-features-complete.cpp
// Demonstrates the C++23 features used across this repository.
// Compile with: g++ -std=c++23 -o cpp23_features_complete cpp23-features-complete.cpp

#include <iostream>
#include <print>
#include <concepts>
#include <expected>
#include <flat_map>
#include <mdspan>
#include <vector>

int main() {
    std::print("=== C++23 Features Demo ===\n\n");
    
    // 1. std::print
    std::print("1. std::print:\n");
    std::print("Hello, C++23!\n");
    std::print("Number: {}\n", 42);
    
    // 2. std::flat_map (an ordered hash map)
    std::print("\n2. std::flat_map:\n");
    std::flat_map<std::string, int> scores = {
        {"Alice", 95}, {"Bob", 87}, {"Charlie", 92}
    };
    for (const auto& [name, score] : scores) {
        std::print("  {}: {}\n", name, score);
    }
    
    // 3. std::mdspan (a view over a multidimensional array)
    std::print("\n3. std::mdspan:\n");
    std::vector<int> data = {1, 2, 3, 4, 5, 6};
    std::mdspan<int, std::extents<std::size_t, 2, 3>> matrix(data.data(), 2, 3);
    for (std::size_t i = 0; i < 2; ++i) {
        for (std::size_t j = 0; j < 3; ++j) {
            // Pack-index subscript (P2259); operator()/at() not in this libstdc++
            std::print("{} ", matrix[i, j]);
        }
        std::print("\n");
    }
    
    // 4. std::expected (C++23)
    std::print("\n4. std::expected:\n");
    std::expected<int, std::string> result = 42;
    if (result) {
        std::print("  Result: {}\n", *result);
    }
    
    std::print("\n=== Demo Complete ===\n");
    return 0;
}
