namespace seafire::common { /// Use an extension of type E. /// template E& extension_context_t:: use() { static std::type_index const key{typeid(E)}; return *(static_cast(use(key))); } /// Use an extension of type E. /// template E const& extension_context_t:: use() const { static std::type_index const key{typeid(E)}; return *(static_cast(use(key))); } /// Add an extension to this context. /// template void extension_context_t:: extend(E* ptr) { static std::type_index const key{typeid(E)}; extend(key, ptr); } /// Erase an extension from this context. /// template void extension_context_t:: erase() { static std::type_index const key{typeid(E)}; erase_extension(key); } template extend_t:: extend_t(extension_context_t& target, extension_type& ext) : target_{target} { target.extend(&ext); } template extend_t:: ~extend_t() noexcept { target_.erase(); } } // namespace seafire::common