diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-01-07 00:00:50 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-01-07 00:00:50 +0100 |
commit | 2778f650bfd8b7ba7825e1cf8a1a28899458649d (patch) | |
tree | 306ca4d63d64422d612c1126687d85609b87e3f8 /modules | |
parent | 8f56be892fe95bbd7b533c9701e68d46f69351c9 (diff) |
core,codec: Adding dangling changes
Diffstat (limited to 'modules')
-rw-r--r-- | modules/codec/c++/csv.h | 18 | ||||
-rw-r--r-- | modules/core/c++/common.cpp | 7 | ||||
-rw-r--r-- | modules/core/c++/common.h | 8 | ||||
-rw-r--r-- | modules/core/c++/error.h | 7 |
4 files changed, 29 insertions, 11 deletions
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<typename Schema, typename FromDecode> struct csv_encode { - static_assert(always_false<T>, "Case not supported"); + static_assert(always_false<Schema, FromDecode>, "Case not supported"); }; -template<typename T, size_t Dim> +template<typename T, size_t Dim, typename FromDecode> struct csv_encode<schema::Array<T,Dim>, FromDecode> { static_assert(Dim == 1, "Only one dimension is allowed."); static_assert(!is_array<T>::value, "Array of an array is not allowed."); @@ -42,13 +42,23 @@ struct csv_encode<schema::Array<T,Dim>, FromDecode> { } }; -template<> +template<typename FromDecode> struct csv_encode<schema::String, FromDecode> { using Schema = schema::String; static error_or<void> encode(const data<Schema, FromDecode>& from, data<Schema, encode::Csv>& to){ - return void_t{}; + return make_error<err::not_implemented>(); + } +}; + +template<class T, size_t N, typename FromDecode> +struct csv_encode<schema::Primitive<T,N>, FromDecode> { + using Schema = schema::Primitive<T,N>; + + static error_or<void> encode(const data<Schema, FromDecode>& from, data<Schema, encode::Csv>& to){ + + return make_error<err::not_implemented>(); } }; } 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 <typename Func> struct return_type_helper<Func, void> { template <typename Func, typename T> using return_type = typename return_type_helper<Func, T>::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 <typename T> struct void_fix { typedef T Type; }; template <> struct void_fix<void> { typedef void_t Type; }; template <typename T> using fix_void = typename void_fix<T>::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<typename T> error make_error(const std::string_view& generic){ error::code id = impl::get_template_id<T>(); |