aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-20 16:00:14 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-03-20 16:00:14 +0100
commitaa2b6bc208785c1d8ced8451478b14433c762896 (patch)
treec179acfad5c3490fecb8898ce7cccfba2649a3e6 /libs
parent8ae0f5a9a83aa58f2bd9eacfb51369b0bf966809 (diff)
downloadteachos-aa2b6bc208785c1d8ced8451478b14433c762896.tar.xz
teachos-aa2b6bc208785c1d8ced8451478b14433c762896.zip
kstd/format: fix type decay for c strings
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/include/kstd/bits/format/args.hpp5
-rw-r--r--libs/kstd/include/kstd/bits/format/formatter.hpp7
-rw-r--r--libs/kstd/include/kstd/bits/format/formatter/cstring.hpp6
-rw-r--r--libs/kstd/include/kstd/bits/format/string.hpp1
4 files changed, 10 insertions, 9 deletions
diff --git a/libs/kstd/include/kstd/bits/format/args.hpp b/libs/kstd/include/kstd/bits/format/args.hpp
index 008cc03..d1586ac 100644
--- a/libs/kstd/include/kstd/bits/format/args.hpp
+++ b/libs/kstd/include/kstd/bits/format/args.hpp
@@ -36,7 +36,7 @@ namespace kstd
template<typename ValueType>
constexpr auto determine_arg_type() -> arg_type
{
- using decay_type = std::remove_cvref_t<std::decay_t<ValueType>>;
+ using decay_type = std::remove_cvref_t<ValueType>;
if constexpr (std::same_as<decay_type, bool>)
{
return arg_type::boolean;
@@ -57,7 +57,8 @@ namespace kstd
{
return arg_type::string_view;
}
- else if constexpr (std::same_as<decay_type, char *> || std::same_as<decay_type, char const *>)
+ else if constexpr (std::same_as<std::decay_t<decay_type>, char *> ||
+ std::same_as<std::decay_t<decay_type>, char const *>)
{
return arg_type::c_string;
}
diff --git a/libs/kstd/include/kstd/bits/format/formatter.hpp b/libs/kstd/include/kstd/bits/format/formatter.hpp
index bff5f55..f391c8e 100644
--- a/libs/kstd/include/kstd/bits/format/formatter.hpp
+++ b/libs/kstd/include/kstd/bits/format/formatter.hpp
@@ -7,7 +7,12 @@ namespace kstd
{
template<typename>
- struct formatter;
+ struct formatter
+ {
+ formatter() = delete;
+ formatter(formatter const &) = delete;
+ auto operator=(formatter const &) -> formatter & = delete;
+ };
} // namespace kstd
diff --git a/libs/kstd/include/kstd/bits/format/formatter/cstring.hpp b/libs/kstd/include/kstd/bits/format/formatter/cstring.hpp
index bf52f2e..9afb974 100644
--- a/libs/kstd/include/kstd/bits/format/formatter/cstring.hpp
+++ b/libs/kstd/include/kstd/bits/format/formatter/cstring.hpp
@@ -5,7 +5,6 @@
#include "../formatter.hpp"
#include "string_view.hpp"
-#include <cstddef>
#include <string_view>
namespace kstd
@@ -25,11 +24,6 @@ namespace kstd
{
};
- template<std::size_t N>
- struct formatter<char[N]> : formatter<std::string_view> // NOLINT
- {
- };
-
} // namespace kstd
#endif \ No newline at end of file
diff --git a/libs/kstd/include/kstd/bits/format/string.hpp b/libs/kstd/include/kstd/bits/format/string.hpp
index edeaed1..40282e4 100644
--- a/libs/kstd/include/kstd/bits/format/string.hpp
+++ b/libs/kstd/include/kstd/bits/format/string.hpp
@@ -28,6 +28,7 @@ namespace kstd
if (current_index == target_index && !found)
{
using decay_type = std::remove_cvref_t<Args>;
+ static_assert(std::is_default_constructible_v<formatter<decay_type>>, "Missing formatter specialization.");
auto fmt = formatter<decay_type>{};
auto it = fmt.parse(context);