A static prefix tree (trie) implementation. Define a compile-time mapping between a constant set of strings and array indices, tuple elements, types, etc. Perfect for parsing things like keywords or field names.
#include <triehard/index.hpp>
using keywords = triehard::index<"connect", "ping", "echo", "exit">;
static_assert(keywords::size = 4);
static_assert(keywords::match("connect") == 0);
static_assert(keywords::match("ping") == 1);
static_assert(keywords::match("echo") == 2);
static_assert(keywords::match("exit") == 3);
static_assert(keywords::match("unknown") == std::nullopt);#include <triehard/named_tuple.hpp>
using my_struct = triehard::named_tuple<type_binding<"a", int>, type_binding<"b", float>>;
static_assert(my_struct{{10, -1.0}}.get<"b">() == -1.0);
//static_assert(my_struct{{10, -1.0}}.get<"c">() == -1.0); // Won't compile!