Compile-Time Magic

Exploring the boundaries of C++ template metaprogramming, type traits, and concepts.

About the Project

Welcome to our research sandbox. This domain hosts internal documentation, benchmarks, and experimental headers focused on modern C++ template metaprogramming techniques (TMP). We specialize in shifting runtime overhead to compile-time evaluations using advanced Type Traits, SFINAE, std::conditional, and C++20 Concepts.

Latest Snippet: Compile-Time Fibonacci with Concepts

Below is a brief demonstration of generating Fibonacci sequences entirely at compile-time using modern C++20 constraints and constexpr evaluation, ensuring zero cost at runtime.

// C++20 Compile-Time Evaluation
#include <iostream>
#include <concepts>

template<unsigned int N>
struct Fibonacci {
    static constexpr unsigned long long value = 
        Fibonacci<N - 1>::value + Fibonacci<N - 2>::value;
};

template<>
struct Fibonacci<0> {
    static constexpr unsigned long long value = 0;
};

template<>
struct Fibonacci<1> {
    static constexpr unsigned long long value = 1;
};

int main() {
    // Evaluated completely by the compiler
    constexpr auto val = Fibonacci<10>::value;
    std::cout << "Fibonacci(10) = " << val << std::endl;
    return 0;
}

Upcoming Research Topics