From 027533a695b1a2a3413a6947e67ba94b51b651fc Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Tue, 7 Apr 2020 15:34:58 +0800 Subject: [PATCH 1/7] Remove the use of the aggregator --- include/ignition/physics/TemplateHelpers.hh | 2 +- .../physics/detail/DeclareDerivedType.hh | 4 +- .../ignition/physics/detail/FeatureList.hh | 50 ++++++++++++++++--- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/include/ignition/physics/TemplateHelpers.hh b/include/ignition/physics/TemplateHelpers.hh index 2f7a2b3d1..a184246c4 100644 --- a/include/ignition/physics/TemplateHelpers.hh +++ b/include/ignition/physics/TemplateHelpers.hh @@ -98,7 +98,7 @@ namespace ignition }; \ \ template \ - using type = typename Implementation::type; \ + struct type : virtual Implementation::type { }; \ }; #endif diff --git a/include/ignition/physics/detail/DeclareDerivedType.hh b/include/ignition/physics/detail/DeclareDerivedType.hh index 2825dc295..23595d499 100644 --- a/include/ignition/physics/detail/DeclareDerivedType.hh +++ b/include/ignition/physics/detail/DeclareDerivedType.hh @@ -41,10 +41,10 @@ public: template \ class Using : \ public virtual ::ignition::physics::detail::ExtractAPI< \ - Select ## Derived, FeaturesT>:: \ + Select ## Derived, typename FeaturesT::FeatureTuple>:: \ template type, \ public virtual ::ignition::physics::detail::ExtractAPI< \ - ::ignition::physics::detail:: Select ## Base, FeaturesT>:: \ + ::ignition::physics::detail:: Select ## Base, typename FeaturesT::FeatureTuple>:: \ template type \ { \ public: using Identifier = Derived ## Identifier; \ diff --git a/include/ignition/physics/detail/FeatureList.hh b/include/ignition/physics/detail/FeatureList.hh index bba4d2b3c..5d51daa81 100644 --- a/include/ignition/physics/detail/FeatureList.hh +++ b/include/ignition/physics/detail/FeatureList.hh @@ -364,12 +364,50 @@ namespace ignition }; ///////////////////////////////////////////////// - template class Selector, typename FeatureListT> - struct ExtractAPI + template class Selector, typename Feature> + struct SplitFeatures; + + ///////////////////////////////////////////////// + template class Selector, typename FeatureTuple> + struct ExtractAPI; + + template class Selector, typename... Features> + struct ExtractAPI> { public: template class type : public virtual - Aggregate::template type { }; + SplitFeatures::template type... { }; + }; + + ///////////////////////////////////////////////// + template class Selector, typename Feature> + struct SplitFeatures + { + template > + struct Implementation + { + template + struct type : + virtual Selector::template type, + virtual Implementation::template type { }; + }; + + template <> + struct Implementation> + { + template + using type = Empty; + }; + + template + struct Implementation> + { + template + using type = typename ExtractAPI::template type; + }; + + template + using type = typename Implementation::template type; }; } @@ -464,7 +502,7 @@ namespace ignition } \ template \ class X : public ::ignition::physics::detail::ExtractAPI< \ - detail::Select ## X, FeaturesT> \ + detail::Select ## X, typename FeaturesT::FeatureTuple> \ ::template type, \ public virtual Entity \ { \ @@ -527,12 +565,12 @@ namespace ignition struct ImplementationSelector { public: template - using type = typename T::template Implementation; + struct type : virtual T::template Implementation { }; }; template using ExtractImplementation = - typename ExtractAPI + typename ExtractAPI ::template type; } } From f42517c454837fbc17d90dcfb2103c1f5818185d Mon Sep 17 00:00:00 2001 From: "Michael X. Grey" Date: Wed, 8 Apr 2020 13:49:05 +0800 Subject: [PATCH 2/7] Use flat and lean inheritance structure --- .../physics/detail/DeclareDerivedType.hh | 4 +- .../ignition/physics/detail/FeatureList.hh | 214 +++++++++++++++--- src/FilterTuple_TEST.cc | 6 +- 3 files changed, 185 insertions(+), 39 deletions(-) diff --git a/include/ignition/physics/detail/DeclareDerivedType.hh b/include/ignition/physics/detail/DeclareDerivedType.hh index 23595d499..2825dc295 100644 --- a/include/ignition/physics/detail/DeclareDerivedType.hh +++ b/include/ignition/physics/detail/DeclareDerivedType.hh @@ -41,10 +41,10 @@ public: template \ class Using : \ public virtual ::ignition::physics::detail::ExtractAPI< \ - Select ## Derived, typename FeaturesT::FeatureTuple>:: \ + Select ## Derived, FeaturesT>:: \ template type, \ public virtual ::ignition::physics::detail::ExtractAPI< \ - ::ignition::physics::detail:: Select ## Base, typename FeaturesT::FeatureTuple>:: \ + ::ignition::physics::detail:: Select ## Base, FeaturesT>:: \ template type \ { \ public: using Identifier = Derived ## Identifier; \ diff --git a/include/ignition/physics/detail/FeatureList.hh b/include/ignition/physics/detail/FeatureList.hh index 5d51daa81..2dbbf1186 100644 --- a/include/ignition/physics/detail/FeatureList.hh +++ b/include/ignition/physics/detail/FeatureList.hh @@ -172,7 +172,7 @@ namespace ignition class ExtractFeatures : public VerifyFeatures { - public: using Result = std::tuple; + public: using type = std::tuple; }; /// \private This specialization of ExtractFeatures is used to wipe away @@ -182,7 +182,7 @@ namespace ignition class ExtractFeatures> : public VerifyFeatures { - public: using Result = std::tuple; + public: using type = std::tuple; }; /// \private This specialization of ExtractFeatures is used to wipe away @@ -195,7 +195,7 @@ namespace ignition void_t> : public VerifyFeatures { - public: using Result = typename SomeFeatureList::Features; + public: using type = typename SomeFeatureList::Features; }; /// \private This specialization skips over any void entries. This allows @@ -204,22 +204,30 @@ namespace ignition template <> class ExtractFeatures { - public: using Result = std::tuple<>; + public: using type = std::tuple<>; }; ///////////////////////////////////////////////// - template + template + struct RedundantTupleFilter + { + template + struct Apply : TupleContainsBase { }; + }; + + ///////////////////////////////////////////////// + template