From 90fdfe725d81596af099cd913adf57afd8d2731b Mon Sep 17 00:00:00 2001 From: mertcandav Date: Sat, 3 Aug 2024 11:00:04 +0300 Subject: [PATCH] api: fix MSVC compatibility of strings --- api/impl_flag.hpp | 4 ++++ api/str.hpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/api/impl_flag.hpp b/api/impl_flag.hpp index cf91c5875..9a5af8579 100644 --- a/api/impl_flag.hpp +++ b/api/impl_flag.hpp @@ -25,4 +25,8 @@ #define __JULE_INLINE_BEFORE_CPP20 inline #endif +#if defined(_MSC_VER) +#define __JULE_COMPILER_MSVC +#endif + #endif // ifndef __JULE_IMPL_FLAG_HPP diff --git a/api/str.hpp b/api/str.hpp index 709f2ad90..e82151b8f 100644 --- a/api/str.hpp +++ b/api/str.hpp @@ -74,7 +74,13 @@ namespace jule Str(void) : _len(0) {}; Str(const jule::Str &src) = default; + +#if defined(__JULE_COMPILER_MSVC) + Str(const std::basic_string &src) : Str(src.begin()->base(), src.end()->base()) {} +#else Str(const std::basic_string &src) : Str(src.begin().base(), src.end().base()) {} +#endif + Str(const char *src, const jule::Int &len) : Str(reinterpret_cast(src), len) {} Str(const jule::U8 *src, const jule::Int &len) : buffer(jule::Str::buffer_t::make(const_cast(src), nullptr)), _slice(const_cast(src)),