diff options
Diffstat (limited to 'modules/core/c++')
-rw-r--r-- | modules/core/c++/reduce_templates.hpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/core/c++/reduce_templates.hpp b/modules/core/c++/reduce_templates.hpp index ef5fa4c..fb643df 100644 --- a/modules/core/c++/reduce_templates.hpp +++ b/modules/core/c++/reduce_templates.hpp @@ -13,23 +13,28 @@ struct tmpl_group_reduce_match { template<typename T0, typename TL0, typename... TL> struct tmpl_group_reduce_match<T0, tmpl_group<TL0,TL...>> { + /** + * Check if type already exists in list + */ static constexpr bool has_type = std::is_same_v<T0,TL0> or tmpl_group_reduce_match<T0, tmpl_group<TL...>>::has_type; using type = typename std::conditional<has_type, tmpl_group<TL0,TL...>, tmpl_group<T0, TL0, TL...>>::type; }; +/** + * Reducing in outer loop + */ template<typename T> struct tmpl_group_reduce { using reduced_type = T; }; -/** - * Reducing in outer loop - */ template<typename... TL, typename T0> struct tmpl_group_reduce<tmpl_group<T0,TL...>> { + // Compile Time outer iteration using reduced_inner_list = typename tmpl_group_reduce<tmpl_group<TL...>>::reduced_type; + // Actual reduction. Basically an inner loop call using reduced_type = typename tmpl_group_reduce_match<T0,reduced_inner_list>::type; }; } |