CRTP mixin implementing the Clonable protocol for a concrete class. More...
#include <clonable.hpp>
Public Member Functions | |
| Base * | clone () const override |
| dispatches to the DEEP_KIND mechanism (default CLONE_DEEP: Derived's copy-constructor) | |
| Base * | sharing_clone () const override |
| dispatches to the SHARING_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention) | |
| Base * | stateless_clone () const override |
| dispatches to the STATELESS_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention) | |
Private Types | |
| enum | Slot { SLOT_CLONE , SLOT_SHARING , SLOT_STATELESS } |
| < inherits Base's constructors, so Derived need not repeat them | |
Private Member Functions | |
| const Derived & | self () const |
| template<CloneKind K, Slot S> | |
| Base * | make () const |
Constructs the clone per CloneKind K, for the override slot S (see Slot). Only the branch selected by K is ever instantiated (if constexpr), so e.g. a class with no weak copy-constructor never instantiates the CLONE_WEAK path just because some OTHER class's Clonable_Impl instantiation elsewhere uses it. | |
CRTP mixin implementing the Clonable protocol for a concrete class.
Usage: class X : public Clonable_Impl<X<args...>, Family_Base<args...> > {...}; Concrete classes never write clone()/sharing_clone()/stateless_clone() bodies of their own – this mixin implements all three uniformly, which is what keeps the clone/sharing flags consistent across the library. The three slot parameters select the mechanism per clone kind; the default is a deep clone via Derived's copy-constructor with the other two kinds deferred to the family base (whose defaults throw).
Notes:
| Derived | the concrete class being equipped (the CRTP self type) |
| Base | the family's abstract base, which must itself derive from Clonable |
| DEEP_KIND | mechanism backing clone() |
| SHARING_KIND | mechanism backing sharing_clone() |
| STATELESS_KIND | mechanism backing stateless_clone() |
|
inlineoverride |
dispatches to the DEEP_KIND mechanism (default CLONE_DEEP: Derived's copy-constructor)
Reimplemented in FST::Clonable_Impl< Criterion_Wrapper_Bias_Estimate< RETURNTYPE, SUBSET, CLASSIFIER, DATAACCESSOR >, Criterion_Wrapper< RETURNTYPE, SUBSET, CLASSIFIER, DATAACCESSOR > >, FST::Clonable_Impl< Data_Splitter_TrainRandom_TestFixed< INTERVALCONTAINER, IDXTYPE, BINTYPE >, Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Result_Tracker_Feature_Stats< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, and FST::Clonable_Impl< Result_Tracker_Regularizer< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET, CRITERION >, Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >.
|
inlineprivate |
Casts to Derived, asserting the dynamic type actually IS Derived (catches a more-derived class that forgot its own Clonable_Impl layer, which would otherwise slice on clone).
|
inlineoverride |
dispatches to the SHARING_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
Reimplemented in FST::Clonable_Impl< Criterion_Wrapper_Bias_Estimate< RETURNTYPE, SUBSET, CLASSIFIER, DATAACCESSOR >, Criterion_Wrapper< RETURNTYPE, SUBSET, CLASSIFIER, DATAACCESSOR > >, FST::Clonable_Impl< Data_Splitter_TrainRandom_TestFixed< INTERVALCONTAINER, IDXTYPE, BINTYPE >, Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Result_Tracker_Feature_Stats< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, and FST::Clonable_Impl< Result_Tracker_Regularizer< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET, CRITERION >, Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >.
|
inlineoverride |
dispatches to the STATELESS_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
Reimplemented in FST::Clonable_Impl< Criterion_Wrapper_Bias_Estimate< RETURNTYPE, SUBSET, CLASSIFIER, DATAACCESSOR >, Criterion_Wrapper< RETURNTYPE, SUBSET, CLASSIFIER, DATAACCESSOR > >, FST::Clonable_Impl< Data_Splitter_TrainRandom_TestFixed< INTERVALCONTAINER, IDXTYPE, BINTYPE >, Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Result_Tracker_Feature_Stats< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, and FST::Clonable_Impl< Result_Tracker_Regularizer< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET, CRITERION >, Result_Tracker_Dupless< RETURNTYPE, IDXTYPE, DIMTYPE, SUBSET >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >.