boost::openmethod::registry_state
The single shared instance of a registry's state.
Synopsis
Declared in <boost/openmethod/preamble.hpp>
template<class Registry>
struct registry_state;
Description
registry_state is a thin, function‐free class whose only member, st, holds all of a registry's mutable state (of type detail::registry_state_type). Reach it through Registry::state().
It is deliberately a separate one‐member class, rather than registry_state_type itself, because sharing the state across a DLL boundary on Windows requires exporting and importing a whole class:
-
MSVC honors
__declspec(dllexport/dllimport)on a class explicit instantiation, but NOT on a variable template (clients silently get a private copy) nor on a static‐data‐member instantiation (error C2720). So the exported symbol must be a class member reached via whole‐class instantiation. -
dllexporting
registry_state_typedirectly would also decorate its member functions and, transitively, the policies' nestedstatetypes, which MSVC rejects (error C2513).
A one‐member, function‐free class is the only shape MSVC will export as a whole and import via extern template.
To share the state across modules, use BOOST_OPENMETHOD_IMPORT_REGISTRY, BOOST_OPENMETHOD_EXPORT_REGISTRY and BOOST_OPENMETHOD_INSTANTIATE_REGISTRY. They hide a platform incompatibility: the export goes on the declaration on ELF and Mach‐O, but on the instantiation on declspec platforms, where extern and __declspec(dllexport) cannot be combined.
// header, every translation unit of a client module:
BOOST_OPENMETHOD_IMPORT_REGISTRY(boost::openmethod::default_registry);
// header, every translation unit of the owning module:
BOOST_OPENMETHOD_EXPORT_REGISTRY(boost::openmethod::default_registry);
// exactly one .cpp of the owning module:
BOOST_OPENMETHOD_INSTANTIATE_REGISTRY(boost::openmethod::default_registry);
See Also
Created with MrDocs