summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix2
-rw-r--r--lib/core/c++/chunk.hpp18
-rw-r--r--lib/core/tests/chunk.cpp37
3 files changed, 46 insertions, 11 deletions
diff --git a/default.nix b/default.nix
index b41c5a8..77abf03 100644
--- a/default.nix
+++ b/default.nix
@@ -39,7 +39,7 @@ let
forstio = (import ((builtins.fetchTarball {
url = "https://git.keldu.de/forstio-forstio/snapshot/master.tar.gz";
- sha256 = "sha256:1l305m2vsm4vxflip9ij9f8q7qbiy85k06kwqi7jwm0b1j23jrin";
+ sha256 = "sha256:12wm3kgrsw3irfnafixrq89vr2gr4h05vc2ybixkgfsnc1znhwlv";
}) + "/default.nix"){
inherit stdenv;
inherit clang-tools;
diff --git a/lib/core/c++/chunk.hpp b/lib/core/c++/chunk.hpp
index 223ceec..1950661 100644
--- a/lib/core/c++/chunk.hpp
+++ b/lib/core/c++/chunk.hpp
@@ -6,26 +6,24 @@ namespace kel {
namespace lbm {
namespace sch {
namespace impl {
-template<typename Sch, uint64_t Ghost, typename LeftG, typename RightG>
-struct chunk_schema_type_helper {
- using Schema = typename chunk_schema_type_helper<Sch,Ghost,LeftG,RightG>::Schema;
-};
+template<typename Sch, uint64_t Ghost, typename LeftG, typename RightG = saw::tmpl_value_group<uint64_t>>
+struct chunk_schema_type_helper;
-template<typename Sch, uint64_t Ghost, typename Side0, typename... Sides, typename... AddedSides>
-struct chunk_schema_type_helper<Sch, Ghost, saw::tmpl_group<Side0,Sides...>, saw::tmpl_group<AddedSides...>> final {
- using Schema = FixedArray<Sch,AddedSides...>;
+template<typename Sch, uint64_t Ghost, uint64_t Side0, uint64_t... Sides, uint64_t... AddedSides>
+struct chunk_schema_type_helper<Sch, Ghost, saw::tmpl_value_group<uint64_t,Side0,Sides...>, saw::tmpl_value_group<uint64_t,AddedSides...>> final {
+ using Schema = typename chunk_schema_type_helper<Sch,Ghost,saw::tmpl_value_group<uint64_t,Sides...>, saw::tmpl_value_group<uint64_t,AddedSides...,(Side0+2u*(Ghost))>>::Schema;
};
template<typename Sch, uint64_t Ghost, uint64_t... AddedSides>
-struct chunk_schema_type_helper<Sch, Ghost, saw::tmpl_group<Side0,Sides...>, saw::tmpl_group<AddedSides...>> final {
+struct chunk_schema_type_helper<Sch, Ghost, saw::tmpl_value_group<uint64_t>, saw::tmpl_value_group<uint64_t,AddedSides...>> final {
using Schema = FixedArray<Sch,AddedSides...>;
};
}
-template<typename Schema, uint64_t Ghost, uint64_t... Side>
+template<typename Sch, uint64_t Ghost, uint64_t... Sides>
struct Chunk {
- using InnerSchema = typename impl::chunk_schema_type_helper<Sch, Ghost, Side...>::Schema;
+ using InnerSchema = typename impl::chunk_schema_type_helper<Sch, Ghost, saw::tmpl_value_group<uint64_t,Sides...>>::Schema;
};
// Not needed for now
diff --git a/lib/core/tests/chunk.cpp b/lib/core/tests/chunk.cpp
new file mode 100644
index 0000000..5110597
--- /dev/null
+++ b/lib/core/tests/chunk.cpp
@@ -0,0 +1,37 @@
+#include <forstio/test/suite.hpp>
+
+#include "../c++/chunk.hpp"
+
+namespace {
+namespace sch {
+using namespace saw::schema;
+}
+
+SAW_TEST("Chunk Ghost size 0"){
+ using namespace kel;
+
+ using TestChunk = lbm::sch::Chunk<sch::UInt32, 0u, 2u, 3u, 4u>;
+ using TestArray = sch::FixedArray<sch::UInt32, 2u, 3u, 4u>;
+
+ SAW_EXPECT((std::is_same_v<TestChunk::InnerSchema,TestArray>), "Types are not identical");
+}
+
+SAW_TEST("Chunk Ghost size 1"){
+ using namespace kel;
+
+ using TestChunk = lbm::sch::Chunk<sch::UInt32, 1u, 2u, 3u, 4u>;
+ using TestArray = sch::FixedArray<sch::UInt32, 4u, 5u, 6u>;
+
+ SAW_EXPECT((std::is_same_v<TestChunk::InnerSchema,TestArray>), "Types are not identical");
+}
+
+SAW_TEST("Chunk Ghost size 3"){
+ using namespace kel;
+
+ using TestChunk = lbm::sch::Chunk<sch::UInt32, 3u, 2u, 3u, 4u,10u,6u>;
+ using TestArray = sch::FixedArray<sch::UInt32, 8u, 9u, 10u,16u,12u>;
+
+ SAW_EXPECT((std::is_same_v<TestChunk::InnerSchema,TestArray>), "Types are not identical");
+}
+
+}