From adfa30f6adafb93a8dd94e3c5cc50251d062852c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 6 Jun 2025 17:21:01 +0200 Subject: [PATCH] Make ssize() return ssize_t in pre-C++20 mode too The return type of ssize() was inconsistent: it returned ssize_t with C++20 but int otherwise. Change the fallback function to conform to the standard one. --- include/private/soci-ssize.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/private/soci-ssize.h b/include/private/soci-ssize.h index e009b96a..57b3a240 100644 --- a/include/private/soci-ssize.h +++ b/include/private/soci-ssize.h @@ -24,13 +24,17 @@ using std::ssize; #else // !C++20 +#include + +using ssize_t = std::make_signed::type; + // Provide simple implementation of C++20 std::ssize() sufficient for our needs // ourselves. template -constexpr int ssize(C const& c) +constexpr ssize_t ssize(C const& c) { - return static_cast(c.size()); + return static_cast(c.size()); } #endif // C++20/!C++20