From cef104281e2118abcecc8f77448886e7f9eedab1 Mon Sep 17 00:00:00 2001 From: Meagan Lang Date: Mon, 12 Aug 2024 13:29:49 -0400 Subject: [PATCH] Handle change in char8_t in C++20 --- include/rapidjson/rapidjson.h | 4 ++++ include/rapidjson/units.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index ee3b1b90e..a0eb583b4 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -585,6 +585,10 @@ RAPIDJSON_NAMESPACE_END #define RAPIDJSON_HAS_CXX11 (RAPIDJSON_CPLUSPLUS >= 201103L) #endif +#ifndef RAPIDJSON_HAS_CXX20 +#define RAPIDJSON_HAS_CXX20 (RAPIDJSON_CPLUSPLUS >= 202002L) +#endif + #ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS #if RAPIDJSON_HAS_CXX11 #define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1 diff --git a/include/rapidjson/units.h b/include/rapidjson/units.h index a0b687101..52ffb18f9 100644 --- a/include/rapidjson/units.h +++ b/include/rapidjson/units.h @@ -515,6 +515,11 @@ class GenericUnitPrefix { GenericUnitPrefix(const std::basic_string abbr0, const double& factor0, const std::basic_string name0) : abbr(abbr0), factor(factor0), name(name0) {} +#if RAPIDJSON_HAS_CXX20 + GenericUnitPrefix(const char8_t* abbr0, const double& factor0, const Ch* name0) : + abbr(reinterpret_cast(abbr0)), + factor(factor0), name(name0) {} +#endif // RAPIDJSON_HAS_CXX20 //! Abbreviation associated with the prefix. std::basic_string abbr; //! Factor that the prefix implies.