From 535498274de9aec26b7baad3df6a9720e9370ede Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Wed, 9 Oct 2024 17:43:08 +0200 Subject: Dangling changes for language things --- modules/core/c++/reduce_templates.hpp | 11 ++++++++--- modules/core/tests/templates.cpp | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 modules/core/tests/templates.cpp (limited to 'modules/core') 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 struct tmpl_group_reduce_match> { + /** + * Check if type already exists in list + */ static constexpr bool has_type = std::is_same_v or tmpl_group_reduce_match>::has_type; using type = typename std::conditional, tmpl_group>::type; }; +/** + * Reducing in outer loop + */ template struct tmpl_group_reduce { using reduced_type = T; }; -/** - * Reducing in outer loop - */ template struct tmpl_group_reduce> { + // Compile Time outer iteration using reduced_inner_list = typename tmpl_group_reduce>::reduced_type; + // Actual reduction. Basically an inner loop call using reduced_type = typename tmpl_group_reduce_match::type; }; } diff --git a/modules/core/tests/templates.cpp b/modules/core/tests/templates.cpp new file mode 100644 index 0000000..2a069a6 --- /dev/null +++ b/modules/core/tests/templates.cpp @@ -0,0 +1,20 @@ +#include "../c++/reduce_templates.hpp" + +#include "../c++/test/suite.hpp" + +namespace { +struct Foo{}; + +struct Bar{}; +struct Baz{}; + +SAW_TEST("Templates/Reduce tmpl_group"){ + using namespace saw; + + using DuplGrp = tmpl_group; + + using UniqGrp = tmpl_group; + + SAW_EXPECT((std::is_same_v), "Expected Uniquess Reduction"); +} +} -- cgit v1.2.3