From 729307460e77f62a532ee9841dcaed9c47f46419 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 26 Jun 2024 09:39:34 +0200 Subject: Added better structure for the data server --- modules/core/c++/reduce_templates.hpp | 41 +++++++++++++++++++++++++++++++++++ modules/core/c++/templates.hpp | 14 ++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 modules/core/c++/reduce_templates.hpp (limited to 'modules/core/c++') diff --git a/modules/core/c++/reduce_templates.hpp b/modules/core/c++/reduce_templates.hpp new file mode 100644 index 0000000..ef5fa4c --- /dev/null +++ b/modules/core/c++/reduce_templates.hpp @@ -0,0 +1,41 @@ +#pragma once + +#include "templates.hpp" + +namespace saw { + +namespace impl { +template +struct tmpl_group_reduce_match { + static constexpr bool has_type = false; + using type = saw::tmpl_group; +}; + +template +struct tmpl_group_reduce_match> { + static constexpr bool has_type = std::is_same_v or tmpl_group_reduce_match>::has_type; + + using type = typename std::conditional, tmpl_group>::type; +}; + +template +struct tmpl_group_reduce { + using reduced_type = T; +}; + +/** + * Reducing in outer loop + */ +template +struct tmpl_group_reduce> { + using reduced_inner_list = typename tmpl_group_reduce>::reduced_type; + + using reduced_type = typename tmpl_group_reduce_match::type; +}; +} + +template +struct tmpl_reduce { + using type = typename impl::tmpl_group_reduce::reduced_type; +}; +} diff --git a/modules/core/c++/templates.hpp b/modules/core/c++/templates.hpp index acbaeb0..70836ae 100644 --- a/modules/core/c++/templates.hpp +++ b/modules/core/c++/templates.hpp @@ -5,6 +5,20 @@ namespace saw { +/** + * This type is meant for grouping of template types + */ +template +struct tmpl_group {}; + +template +struct tmpl_concat; + +template +struct tmpl_concat, tmpl_group> { + using type = tmpl_group; +}; + template struct parameter_pack_index; template struct parameter_pack_index { -- cgit v1.2.3