A C++20 template metaprogramming library for manipulating types as collections. This library enables functional-style operations on types at compile time.
typename-array provides a set of metaprogramming utilities for treating types as values that can be stored in collections, transformed, and manipulated through various operations. The library implements a compile-time "array of types" that functions similarly to standard containers, but operates entirely at compile time.
This project was primarily created as a learning exercise in template metaprogramming.
I mainly use AI to generate the tests and documentation, so they might be not ideal.
- Type Collections: Store and manipulate collections of types with
typename_array<Types...> - Type Manipulation: Transform, filter, find, and combine types using functional-style operations
- Compile-time Calculations: 'static_calc' is not actually useful because C++ already has constexpr, but it is a good example of how to use the library
- Type Binding: Bind types to template placeholders with
typename_binder
typename_array<Types...>: The core container for storing multiple typescombine<Array1, Array2>: Concatenates two type arraysget<Index, Array>: Retrieves a type at a specific indexfind<Array, Type>: Finds the index of a type in an arraycount<Array, Type>: Counts occurrences of a type in an array
apply<Array, Function>: Maps a transformation function to each type in an arraycut<Start, End, Array>: Extracts a subrange of types from an arrayreplace<Index, Array, NewType>: Replaces a type at a specific indexinsert<Index, Array, Type>: Inserts a type at a specific positioncheck_for_allowed_types<Array, AllowedTypes>: Validates types against a whitelist
typename_binder<Template, Types...>: Creates flexible templates with placeholder substitutionsymbols_to_int<Symbols...>: Converts character value types to integersint_to_symbols<Value>: Converts integers to character value types
- C++20 compatible compiler
- Initially depended on MSVC++ quirks, but now should compile with clang and gcc as well