From aa2ecacd2e477eb5748f060d33138e0c12c0634f Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 27 Nov 2023 23:03:57 +0100 Subject: codec,core,tools: Adding dangling experimental changes --- c++/core/mcts.h | 5 +++ c++/core/platonic.h | 103 ++++++++++++++++++++++++++++++++++++++++++++++ c++/core/string_literal.h | 2 +- c++/core/templates.h | 6 +++ 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 c++/core/mcts.h create mode 100644 c++/core/platonic.h (limited to 'c++/core') diff --git a/c++/core/mcts.h b/c++/core/mcts.h new file mode 100644 index 0000000..30eed2f --- /dev/null +++ b/c++/core/mcts.h @@ -0,0 +1,5 @@ +#pragma once + +namespace saw { + +} diff --git a/c++/core/platonic.h b/c++/core/platonic.h new file mode 100644 index 0000000..eefe99f --- /dev/null +++ b/c++/core/platonic.h @@ -0,0 +1,103 @@ +#pragma once + +#include "error.h" + +namespace saw { +namespace impl { +/** + * + */ +template +struct platonic_helper { + static_assert(always_false, "Unsupported platonic body. Alternatively it's not a platonic body"); +}; + +template +struct platonic_helper { + static constexpr surface_edges = 3u; +/* + static constexpr std::array, 4u> normals = { + {0.0, 0.0, -1.0}, // 1 + {}, // 2 + {}, // 3 + {} // 4 + }; +*/ +}; + +template +struct platonic_helper { + static constexpr surface_edges = 4u; + + static constexpr std::array, 6u> normals = { + { 1.0, 0.0, 0.0}, // 1 + {-1.0, 0.0, 0.0}, // 2 + { 0.0, 1.0, 0.0}, // 3 + { 0.0,-1.0, 0.0}, // 4 + { 0.0, 0.0, 1.0}, // 5 + { 0.0, 0.0,-1.0} // 6 + }; +}; + +template +struct platonic_helper { + static constexpr uint8_t surface_edges = 3u; +/* + static constexpr std::array, 20u> normals = { + {}, // 1 + {}, // 2 + {}, // 3 + {}, // 4 + {}, // 5 + {}, // 6 + {}, // 7 + {}, // 8 + {}, // 9 + {}, // 10 + {}, // 11 + {}, // 12 + {}, // 13 + {}, // 14 + {}, // 15 + {}, // 16 + {}, // 17 + {}, // 18 + {}, // 19 + {} // 20 + }; +*/ +}; +} +/** + * Container for describing each platonic body with + * helpers describing the orientation of each body. + */ +template +class platonic { +private: + /** + * Storage for the surfaces + */ + std::array surfaces_; +public: + constexpr uint8_t get_surface_edge_size() constexpr { + return platonic_helper::surface_edges; + } + + constexpr uint8_t get_surface_size() constexpr { + return N; + } + + T& at(uint8_t i){ + return surface_.at(i); + } + + const T& at(uint8_t i) const { + return surface_.at(i); + } + + constexpr std::array& get_surface_normal(size_t i) constexpr { + + } +}; +} diff --git a/c++/core/string_literal.h b/c++/core/string_literal.h index 7373d5c..30f62fd 100644 --- a/c++/core/string_literal.h +++ b/c++/core/string_literal.h @@ -51,7 +51,7 @@ public: }; template -constexpr string_literal operator""_sl() { +constexpr string_literal operator""_sl() { return string_literal{{Chars..., '\0'}}; } } // namespace saw diff --git a/c++/core/templates.h b/c++/core/templates.h index e2851a0..2eb0f7e 100644 --- a/c++/core/templates.h +++ b/c++/core/templates.h @@ -105,6 +105,8 @@ struct ct_multiply { namespace impl { template struct ct_convert_digits_table_helper { + static_assert(i <= 15, "Only conversion up to hex is supported"); + static constexpr std::array table = { '0', '1', '2', '3', '4', '5', '6', '7', @@ -119,18 +121,21 @@ template struct ct_convert_digits_helper { static constexpr size_t size = ct_convert_digits_helper::size; static constexpr std::array value = ct_convert_digits_helper::value; + static constexpr string_literal literal = ct_convert_digits_helper::literal; }; template struct ct_convert_digits_helper<0, Base, Digs...> { static constexpr size_t size = sizeof...(Digs); static constexpr std::array value = {Digs...}; + static constexpr string_literal literal = {{ct_convert_digits_table_helper::value..., '\0'}}; }; template struct ct_convert_digits_helper<0, Base> { static constexpr size_t size = 0; static constexpr std::array value = {0}; + static constexpr string_literal literal = "0"_sl; }; } @@ -140,5 +145,6 @@ struct ct_convert_to_digits { static constexpr size_t size = impl::ct_convert_digits_helper::size; static constexpr std::array value = impl::ct_convert_digits_helper::value; + static constexpr string_literal literal = impl::ct_convert_digits_helper::literal; }; } -- cgit v1.2.3