diff --git a/src/backend/backend_concept.h b/src/backend/backend_concept.h index 2ee1942..0717c49 100644 --- a/src/backend/backend_concept.h +++ b/src/backend/backend_concept.h @@ -3,6 +3,7 @@ #ifdef __cpp_concepts # include # include "../ds/concept.h" +# include "../pal/pal_concept.h" namespace snmalloc { @@ -52,6 +53,44 @@ namespace snmalloc template concept ConceptBackendMetaRange = ConceptBackendMeta && ConceptBackendMeta_Range; + + class CommonConfig; + struct Flags; + + /** + * Backend global objects of type T must obey a number of constraints. They + * must... + * + * * inherit from CommonConfig (see commonconfig.h) + * * specify which PAL is in use via T::Pal + * * have static pagemap accessors via T::Pagemap + * * define a T::LocalState type + * * define T::Options of type snmalloc::Flags + * * expose the global allocator pool via T::pool() + * + */ + template + concept ConceptBackendGlobals = + std::is_base_of::value && + ConceptPAL && + ConceptBackendMetaRange && + requires() + { + typename Globals::LocalState; + + { Globals::Options } -> ConceptSameModRef; + + typename Globals::GlobalPoolState; + { Globals::pool() } -> ConceptSame; + }; + + /** + * The lazy version of the above; please see ds/concept.h and use sparingly. + */ + template + concept ConceptBackendGlobalsLazy = + !is_type_complete_v || ConceptBackendGlobals; + } // namespace snmalloc #endif