]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/ceph-dencoder/sstring.h: use `char8_t` instead of `unsigned char`
authorMax Kellermann <max.kellermann@ionos.com>
Sat, 2 Nov 2024 21:32:23 +0000 (22:32 +0100)
committerMax Kellermann <max.kellermann@ionos.com>
Mon, 9 Dec 2024 12:06:00 +0000 (13:06 +0100)
This fixes a build failure with libc++ (clang/LLVM).  This build
failure is correct: there exists no specialization for
`std::char_traits<unsigned char>`.  The standards-compliant way to use
unsigned chars in strings is to use `char8_t`.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/common/sstring.hh
src/tools/ceph-dencoder/sstring.h

index b0fcd9b5c47d22bc1e5cd053fd0e9d7b14bdd220..7e0d6c6b1e2ec881e556d08d72c0ab4cd90ce433 100644 (file)
@@ -44,6 +44,7 @@ template <typename char_type, typename Size, Size max_size>
 class basic_sstring {
     static_assert(
             (std::is_same<char_type, char>::value
+             || std::is_same<char_type, char8_t>::value
              || std::is_same<char_type, signed char>::value
              || std::is_same<char_type, unsigned char>::value),
             "basic_sstring only supports single byte char types");
index c2493c10efae69fa6bd4fa65839fee9323b4157f..829a0eb307f635ffc2b9de0766929ba95c73211b 100644 (file)
@@ -7,7 +7,7 @@
 class sstring_wrapper {
   using sstring16 = basic_sstring<char, uint32_t, 16>;
   sstring16 s1;
-  using sstring24 = basic_sstring<unsigned char, uint16_t, 24>;
+  using sstring24 = basic_sstring<char8_t, uint16_t, 24>;
   sstring24 s2;
  public:
   sstring_wrapper() = default;