Skip to content

Instantly share code, notes, and snippets.

View unrays's full-sized avatar
🌀
Template Metaprogramming Cat

Félix-Olivier Dumas unrays

🌀
Template Metaprogramming Cat
View GitHub Profile
@unrays
unrays / exotic_lib_api_idiom.hpp
Last active October 6, 2026 22:43
The Exotic Library API Idiom: a simple structure for separating internals from the public interface. Yeah, I really love naming things!
// Copyright (c) October 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
namespace exotic::internal::foo {
namespace detail {
template<typename T>
struct impl {
using value_type = T;
@unrays
unrays / transform_tuple.hpp
Last active October 2, 2026 14:58
Simple, elegant, extremely readable, and fluid C++ utility to transform tuple types using metafunctions.
// Copyright (c) October 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
namespace exotic {
template<template<typename> typename...>
struct transform_tuple_using;
template<template<typename> typename Metafunction>
struct transform_tuple_using<Metafunction> {
@unrays
unrays / spo.hpp
Last active September 22, 2026 22:04
C++ implementation of the Subobject Polymorphic Overlay (SPO) pattern.
// Copyright (c) 2026 Félix-Olivier Dumas.
// Free to use, modify, and distribute for educational or commercial purposes.
// Reference example of the SPO pattern (simplified form)
namespace exotic {
template<template<typename> typename Target, typename Source>
[[nodiscard]] constexpr auto& view_cast(Source& src) noexcept {
return reinterpret_cast<Target<Source>&>(src);
@unrays
unrays / cxx26-basic-experiments.cpp
Last active September 15, 2026 14:27
A small experiment with C++26 reflection and std::meta.
// Copyright (c) September 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
// using x86-64 clang (reflection - C++26) [-freflection-latest -std=c++26]
#include <experimental/meta>
#include <iostream>
#include <string_view>
struct Point {
@unrays
unrays / compile-time-token-keyword-categorizer.cppm
Last active September 15, 2026 14:20
COMPILE-TIME KEYWORD-TO-TOKEN CATEGORIZATION SYSTEM - This code comes from an unfinished project of mine. I found certain parts quite interesting, so I extracted a few of them and turned them into gists. This code is for educational purposes and is not functional, as it requires the rest of the architecture to work.
// Copyright (c) July 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
template<typename entry_tuple>
struct TokenKeywordCategorizerConfigurationSchema {
using first_t = std::decay_t<std::tuple_element_t<0, entry_tuple>>;
using second_t = std::decay_t<std::tuple_element_t<1, entry_tuple>>;
static constexpr bool valid =
requires {
@unrays
unrays / compile-time-enum-mapper.cppm
Last active September 15, 2026 14:20
COMPILE-TIME BIDIRECTIONAL ENUM MAPPING SYSTEM - This code comes from an unfinished project of mine. I found certain parts quite interesting, so I extracted a few of them and turned them into gists. This code is for educational purposes and is not functional, as it requires the rest of the architecture to work.
// Copyright (c) July 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
template<typename entry_tuple>
struct EnumMapperConfigurationSchema {
using first_t = std::decay_t<std::tuple_element_t<0, entry_tuple>>;
using second_t = std::decay_t<std::tuple_element_t<1, entry_tuple>>;
static constexpr bool valid =
requires {
@unrays
unrays / compile-time-static-dfa.cppm
Last active September 15, 2026 14:20
COMPILE-TIME DFA GENERATION PIPELINE AND FLAT TRANSITION MATRIX - This code comes from an unfinished project of mine. I found certain parts quite interesting, so I extracted a few of them and turned them into gists. This code is for educational purposes and is not functional, as it requires the rest of the architecture to work.
// Copyright (c) July 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
template<std::size_t R, std::size_t C>
struct StaticMatrix final {
public:
template<typename... Args>
requires (sizeof...(Args) == (R * C))
&& (std::convertible_to<Args, int> && ...)
consteval StaticMatrix(Args... entries)
@unrays
unrays / compile-time-lexer-architecture.cppm
Last active September 15, 2026 14:21
COMPILE-TIME LEXER ASSEMBLY AND DFA CONFIGURATION - This code comes from an unfinished project of mine. I found certain parts quite interesting, so I extracted a few of them and turned them into gists. This code is for educational purposes and is not functional, as it requires the rest of the architecture to work.
// Copyright (c) July 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
#if !defined(__INTELLISENSE__)
using LexingAutomaton__final = StaticDFA<
generate_expanded_dfa_config_t<
ENABLED <nttp_to_type<LexState::Start>, charset_alpha, nttp_to_type<LexState::Identifier>>,
ENABLED <nttp_to_type<LexState::Start>, charset_digits, nttp_to_type<LexState::Number>>,
ENABLED <nttp_to_type<LexState::Start>, charset<':'>, nttp_to_type<LexState::DelimiterColon>>,
@unrays
unrays / sharded-string-interner.hpp
Created May 24, 2026 20:19
High-performance sharded string interner using custom memory allocation and low-contention concurrency design.
// Copyright (c) May 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
#pragma once
#include <cstddef>
#include <stdexcept>
#include <atomic>
#include <iostream>
#include <new>
@unrays
unrays / exotic_crtp.hpp
Created May 22, 2026 20:00
Exotic CRTP pattern for static polymorphism using variadic mixin composition and C++23 explicit object parameters. Introduces a novel approach to compile-time interface dispatch without runtime overhead.
// Copyright (c) May 2026 Félix-Olivier Dumas. All rights reserved.
// Licensed under the terms described in the LICENSE file
// Reference example of the pattern
// See: https://medium.com/@felixolivierdumas/exotic-crtp-rethinking-static-polymorphism-with-c-23-89f9e75e8ffd
#pragma once
#include <iostream>
#include <type_traits>