Intrusive Concepts
-
template<typename C>
concept csg::stateless A type is stateless if it is empty, trivially constructible, and trivially destructible. Together, these properties ensure that there is no need to store a reference to a specific instance of a stateless class, because constructing a new instance on the fly has no cost and is always equivalent:
Both instances have the same data, because they are both empty
The creation and destruction of the new instance are side-effect-free because the constructor and destructor are trivial (and are therefore no-ops that will be optimized away)
See also
The documentation for
csg::compressed_invocable_refcontains an explanation of how this is used in CSD.
-
template<typename T>
concept csg::optional_size This concept is satisfied when the type is an integral type or when it is the special empty struct
csg::no_size. The intention is to allow containers to either store their size inline (so that std::size will be \(O(1)\)) or to save space and compute it on the fly (but then std::size will be \(O(n)\)). This is usually done by accepting the size type as a template parameter, which is constrained to to be anoptional_size. The size member variable itself is usually declared with [[no_unique_address]], so that it does not take any space when it iscsg::no_size.