Skip to content

Instantly share code, notes, and snippets.

@yaqwsx
Last active July 29, 2021 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaqwsx/b7f96938a866414f733d4ed135bb876d to your computer and use it in GitHub Desktop.
Save yaqwsx/b7f96938a866414f733d4ed135bb876d to your computer and use it in GitHub Desktop.
// Approach used in DIOS
class Base {};
template < typename Next >
class FatureA: public < Next > {};
template < typename Next >
class FeatureB: public < Next > {};
using MyType = FeatureB < FeatureA < FeatureB< Base > >;
// Alternative
template< template < typename > typename... Features >
class Base: public Features< Base < Features... > >... {};
template < typename Self >
class FatureA {
CRTP_SELF();
// Access other components via self().something
};
template < typename Self >
class FatureB {
CRTP_SELF();
// Access other components via self().something
};
using MyType = Base< FeatureA, FeatureB >;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment