From 4fb632ce3d79d80ab41de697f4fd4b2809d337e5 Mon Sep 17 00:00:00 2001 From: Francois BIOT Date: Sun, 19 Feb 2023 06:04:54 +0100 Subject: [PATCH] [TinyString] change size_t to be more tolerant with signed ints --- src/TinyString.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/TinyString.h b/src/TinyString.h index 32c7958..42a6b1c 100644 --- a/src/TinyString.h +++ b/src/TinyString.h @@ -8,9 +8,20 @@ class TinyString { public: - using size_t = uint16_t; + class size_t + { + public: + using type = uint16_t; + size_t (const size_t& s) : s_(s) {} + size_t (int i) : s_(static_cast) {} + + type operator() const { return s_; } + + private: + type s_; + }; using value_type = char; - static constexpr size_t npos = std::numeric_limits::max(); + constexpr size_t::type npos = std::numeric_limits::max(); TinyString() = default; TinyString(int, int base=10);