From 2778f650bfd8b7ba7825e1cf8a1a28899458649d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 7 Jan 2024 00:00:50 +0100 Subject: core,codec: Adding dangling changes --- modules/codec/c++/csv.h | 18 ++++++++++++++---- modules/core/c++/common.cpp | 7 +++++++ modules/core/c++/common.h | 8 ++++++++ modules/core/c++/error.h | 7 ------- 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 modules/core/c++/common.cpp diff --git a/modules/codec/c++/csv.h b/modules/codec/c++/csv.h index 3727829..f40376f 100644 --- a/modules/codec/c++/csv.h +++ b/modules/codec/c++/csv.h @@ -12,10 +12,10 @@ struct Csv {}; namespace impl { template struct csv_encode { - static_assert(always_false, "Case not supported"); + static_assert(always_false, "Case not supported"); }; -template +template struct csv_encode, FromDecode> { static_assert(Dim == 1, "Only one dimension is allowed."); static_assert(!is_array::value, "Array of an array is not allowed."); @@ -42,13 +42,23 @@ struct csv_encode, FromDecode> { } }; -template<> +template struct csv_encode { using Schema = schema::String; static error_or encode(const data& from, data& to){ - return void_t{}; + return make_error(); + } +}; + +template +struct csv_encode, FromDecode> { + using Schema = schema::Primitive; + + static error_or encode(const data& from, data& to){ + + return make_error(); } }; } diff --git a/modules/core/c++/common.cpp b/modules/core/c++/common.cpp new file mode 100644 index 0000000..4812c66 --- /dev/null +++ b/modules/core/c++/common.cpp @@ -0,0 +1,7 @@ +#include "common.h" + +namespace saw { +void_t make_void(){ + return {}; +} +} diff --git a/modules/core/c++/common.h b/modules/core/c++/common.h index a06c238..d892efe 100644 --- a/modules/core/c++/common.h +++ b/modules/core/c++/common.h @@ -60,8 +60,16 @@ template struct return_type_helper { template using return_type = typename return_type_helper::Type; +/** + * Struct describing a void type + */ struct void_t {}; +/** + * Helper function since changing returns between void_t{} and make_error<...>() is a bit annoying. + */ +void_t make_void(); + template struct void_fix { typedef T Type; }; template <> struct void_fix { typedef void_t Type; }; template using fix_void = typename void_fix::Type; diff --git a/modules/core/c++/error.h b/modules/core/c++/error.h index 581782d..2728c8e 100644 --- a/modules/core/c++/error.h +++ b/modules/core/c++/error.h @@ -144,13 +144,6 @@ error::code get_template_id(){ } } -/** - * Helper function since changing returns between void_t{} and make_error<...>() is a bit annoying. - */ -void_t make_void(){ - return {}; -} - template error make_error(const std::string_view& generic){ error::code id = impl::get_template_id(); -- cgit v1.2.3