#pragma once #include #include #include #include #include "common.h" #include namespace rng::init { using ctor_func = std::function; struct DCLookupFailed final : std::exception{ inline DCLookupFailed(const std::string_view& n) : std::exception(), name(std::move(n)){} std::string name; }; const ctor_func& apply_raw(std::string_view name, ctor_func fn) noexcept; template inline auto apply(std::string_view name, auto&& lam) noexcept { return apply_raw(name, [lam](const void* seed) -> Random* { return static_cast(lam(reinterpret_cast(seed))); }); } ctor_func& get(std::string_view name); } // To add to dynamic CTOR map #define RNGXX_APPLY_CTOR(ns, T, TSeed) __attribute__((used, retain))\ const static auto& RNGXX_DCTOR_NAME(T) = rng::init::apply(#T, [](const TSeed* ptr) { return new ns::T(*ptr); }) //const extern init::ctor_func& RNGXX_DCTOR_NAME(sm64);