diff --git a/include/ctll/fixed_string.hpp b/include/ctll/fixed_string.hpp index 94d06e5e..01c6ab5e 100644 --- a/include/ctll/fixed_string.hpp +++ b/include/ctll/fixed_string.hpp @@ -6,6 +6,8 @@ #include #include +#include "utilities.hpp" + namespace ctll { struct length_value_t { @@ -130,12 +132,14 @@ template struct fixed_string { } } real_size = out; +#ifndef CTLL_NO_WCHAR_T } else if constexpr (std::is_same_v || std::is_same_v) { for (size_t i{0}; i < N; ++i) { - content[i] = static_cast(input[i]); - if ((i == (N-1)) && (input[i] == 0)) break; - real_size++; - } + content[i] = static_cast(input[i]); + if ((i == (N - 1)) && (input[i] == 0)) break; + real_size++; + } +#endif } } constexpr fixed_string(const fixed_string & other) noexcept { diff --git a/include/ctll/utilities.hpp b/include/ctll/utilities.hpp index fbb9f37f..db2c4a35 100644 --- a/include/ctll/utilities.hpp +++ b/include/ctll/utilities.hpp @@ -40,6 +40,13 @@ #define CTLL_FORCE_INLINE __attribute__((always_inline)) #endif +#ifdef _LIBCPP_VERSION +#ifdef _LIBCPP_HAS_NO_WIDE_CHARACTERS +#define CTLL_NO_WCHAR_T +#else +#endif +#endif + namespace ctll { template struct conditional_helper; diff --git a/include/ctre/utility.hpp b/include/ctre/utility.hpp index 890aa21b..0262c785 100644 --- a/include/ctre/utility.hpp +++ b/include/ctre/utility.hpp @@ -4,6 +4,9 @@ #include "../ctll/utilities.hpp" #define CTRE_CNTTP_COMPILER_CHECK CTLL_CNTTP_COMPILER_CHECK +#ifdef CTLL_NO_WCHAR_T +#define CTRE_NO_WCHAR_T +#endif #if __GNUC__ > 9 #if __has_cpp_attribute(likely) diff --git a/include/ctre/wrapper.hpp b/include/ctre/wrapper.hpp index 55e35b48..7d591de8 100644 --- a/include/ctre/wrapper.hpp +++ b/include/ctre/wrapper.hpp @@ -32,27 +32,29 @@ struct zero_terminated_string_end_iterator { constexpr CTRE_FORCE_INLINE friend bool operator==(const char * ptr, zero_terminated_string_end_iterator) noexcept { return *ptr == '\0'; } - constexpr CTRE_FORCE_INLINE friend bool operator==(const wchar_t * ptr, zero_terminated_string_end_iterator) noexcept { + constexpr CTRE_FORCE_INLINE friend bool operator!=(const char * ptr, zero_terminated_string_end_iterator) noexcept { + return *ptr != '\0'; + } + constexpr CTRE_FORCE_INLINE friend bool operator==(zero_terminated_string_end_iterator, const char * ptr) noexcept { + return *ptr == '\0'; + } + constexpr CTRE_FORCE_INLINE friend bool operator!=(zero_terminated_string_end_iterator, const char * ptr) noexcept { + return *ptr != '\0'; + } +#ifndef CTLL_NO_WCHAR_T + constexpr CTRE_FORCE_INLINE friend bool operator==(const wchar_t * ptr, zero_terminated_string_end_iterator) noexcept { return *ptr == 0; } - constexpr CTRE_FORCE_INLINE friend bool operator!=(const char * ptr, zero_terminated_string_end_iterator) noexcept { - return *ptr != '\0'; - } constexpr CTRE_FORCE_INLINE friend bool operator!=(const wchar_t * ptr, zero_terminated_string_end_iterator) noexcept { return *ptr != 0; - } - constexpr CTRE_FORCE_INLINE friend bool operator==(zero_terminated_string_end_iterator, const char * ptr) noexcept { - return *ptr == '\0'; - } - constexpr CTRE_FORCE_INLINE friend bool operator==(zero_terminated_string_end_iterator, const wchar_t * ptr) noexcept { - return *ptr == 0; - } - constexpr CTRE_FORCE_INLINE friend bool operator!=(zero_terminated_string_end_iterator, const char * ptr) noexcept { - return *ptr != '\0'; - } - constexpr CTRE_FORCE_INLINE friend bool operator!=(zero_terminated_string_end_iterator, const wchar_t * ptr) noexcept { - return *ptr != 0; - } + } + constexpr CTRE_FORCE_INLINE friend bool operator==(zero_terminated_string_end_iterator, const wchar_t * ptr) noexcept { + return *ptr == 0; + } + constexpr CTRE_FORCE_INLINE friend bool operator!=(zero_terminated_string_end_iterator, const wchar_t * ptr) noexcept { + return *ptr != 0; + } +#endif }; template class RangeLikeType { @@ -181,9 +183,11 @@ template struct regular_expres static constexpr CTRE_FORCE_INLINE auto exec(std::string_view sv) noexcept { return exec(sv.begin(), sv.end()); } +#ifndef CTRE_NO_WCHAR_T static constexpr CTRE_FORCE_INLINE auto exec(std::wstring_view sv) noexcept { return exec(sv.begin(), sv.end()); } +#endif #ifdef CTRE_ENABLE_UTF8_RANGE static constexpr CTRE_FORCE_INLINE auto exec(std::u8string_view sv) noexcept { return exec_with_result_iterator(utf8_range(sv).begin(), utf8_range(sv).end());