Skip to content

Commit d7939ff

Browse files
author
Hana Dusíková
committed
update of single-header versions
1 parent b65dcd0 commit d7939ff

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

single-header/ctre-unicode.hpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,13 +1731,15 @@ namespace ctre {
17311731

17321732
template <auto... Name> struct id {
17331733
static constexpr auto name = ctll::fixed_string<sizeof...(Name)>{{Name...}};
1734-
};
17351734

1736-
template <auto... Name> constexpr auto operator==(id<Name...>, id<Name...>) noexcept -> std::true_type { return {}; }
1735+
friend constexpr auto operator==(id<Name...>, id<Name...>) noexcept -> std::true_type { return {}; }
17371736

1738-
template <auto... Name1, auto... Name2> constexpr auto operator==(id<Name1...>, id<Name2...>) noexcept -> std::false_type { return {}; }
1737+
template <auto... Other> friend constexpr auto operator==(id<Name...>, id<Other...>) noexcept -> std::false_type { return {}; }
17391738

1740-
template <auto... Name, typename T> constexpr auto operator==(id<Name...>, T) noexcept -> std::false_type { return {}; }
1739+
template <typename T> friend constexpr auto operator==(id<Name...>, T) noexcept -> std::false_type { return {}; }
1740+
1741+
template <typename T> friend constexpr auto operator==(T, id<Name...>) noexcept -> std::false_type { return {}; }
1742+
};
17411743

17421744
}
17431745

@@ -4025,16 +4027,28 @@ namespace ctre {
40254027

40264028
struct zero_terminated_string_end_iterator {
40274029
constexpr inline zero_terminated_string_end_iterator() = default;
4028-
constexpr CTRE_FORCE_INLINE bool operator==(const char * ptr) const noexcept {
4030+
constexpr CTRE_FORCE_INLINE friend bool operator==(const char * ptr, zero_terminated_string_end_iterator) noexcept {
4031+
return *ptr == '\0';
4032+
}
4033+
constexpr CTRE_FORCE_INLINE friend bool operator==(const wchar_t * ptr, zero_terminated_string_end_iterator) noexcept {
4034+
return *ptr == 0;
4035+
}
4036+
constexpr CTRE_FORCE_INLINE friend bool operator!=(const char * ptr, zero_terminated_string_end_iterator) noexcept {
4037+
return *ptr != '\0';
4038+
}
4039+
constexpr CTRE_FORCE_INLINE friend bool operator!=(const wchar_t * ptr, zero_terminated_string_end_iterator) noexcept {
4040+
return *ptr != 0;
4041+
}
4042+
constexpr CTRE_FORCE_INLINE friend bool operator==(zero_terminated_string_end_iterator, const char * ptr) noexcept {
40294043
return *ptr == '\0';
40304044
}
4031-
constexpr CTRE_FORCE_INLINE bool operator==(const wchar_t * ptr) const noexcept {
4045+
constexpr CTRE_FORCE_INLINE friend bool operator==(zero_terminated_string_end_iterator, const wchar_t * ptr) noexcept {
40324046
return *ptr == 0;
40334047
}
4034-
constexpr CTRE_FORCE_INLINE bool operator!=(const char * ptr) const noexcept {
4048+
constexpr CTRE_FORCE_INLINE friend bool operator!=(zero_terminated_string_end_iterator, const char * ptr) noexcept {
40354049
return *ptr != '\0';
40364050
}
4037-
constexpr CTRE_FORCE_INLINE bool operator!=(const wchar_t * ptr) const noexcept {
4051+
constexpr CTRE_FORCE_INLINE friend bool operator!=(zero_terminated_string_end_iterator, const wchar_t * ptr) noexcept {
40384052
return *ptr != 0;
40394053
}
40404054
};

single-header/ctre.hpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,13 +1728,15 @@ namespace ctre {
17281728

17291729
template <auto... Name> struct id {
17301730
static constexpr auto name = ctll::fixed_string<sizeof...(Name)>{{Name...}};
1731-
};
17321731

1733-
template <auto... Name> constexpr auto operator==(id<Name...>, id<Name...>) noexcept -> std::true_type { return {}; }
1732+
friend constexpr auto operator==(id<Name...>, id<Name...>) noexcept -> std::true_type { return {}; }
17341733

1735-
template <auto... Name1, auto... Name2> constexpr auto operator==(id<Name1...>, id<Name2...>) noexcept -> std::false_type { return {}; }
1734+
template <auto... Other> friend constexpr auto operator==(id<Name...>, id<Other...>) noexcept -> std::false_type { return {}; }
17361735

1737-
template <auto... Name, typename T> constexpr auto operator==(id<Name...>, T) noexcept -> std::false_type { return {}; }
1736+
template <typename T> friend constexpr auto operator==(id<Name...>, T) noexcept -> std::false_type { return {}; }
1737+
1738+
template <typename T> friend constexpr auto operator==(T, id<Name...>) noexcept -> std::false_type { return {}; }
1739+
};
17381740

17391741
}
17401742

@@ -4022,16 +4024,28 @@ namespace ctre {
40224024

40234025
struct zero_terminated_string_end_iterator {
40244026
constexpr inline zero_terminated_string_end_iterator() = default;
4025-
constexpr CTRE_FORCE_INLINE bool operator==(const char * ptr) const noexcept {
4027+
constexpr CTRE_FORCE_INLINE friend bool operator==(const char * ptr, zero_terminated_string_end_iterator) noexcept {
4028+
return *ptr == '\0';
4029+
}
4030+
constexpr CTRE_FORCE_INLINE friend bool operator==(const wchar_t * ptr, zero_terminated_string_end_iterator) noexcept {
4031+
return *ptr == 0;
4032+
}
4033+
constexpr CTRE_FORCE_INLINE friend bool operator!=(const char * ptr, zero_terminated_string_end_iterator) noexcept {
4034+
return *ptr != '\0';
4035+
}
4036+
constexpr CTRE_FORCE_INLINE friend bool operator!=(const wchar_t * ptr, zero_terminated_string_end_iterator) noexcept {
4037+
return *ptr != 0;
4038+
}
4039+
constexpr CTRE_FORCE_INLINE friend bool operator==(zero_terminated_string_end_iterator, const char * ptr) noexcept {
40264040
return *ptr == '\0';
40274041
}
4028-
constexpr CTRE_FORCE_INLINE bool operator==(const wchar_t * ptr) const noexcept {
4042+
constexpr CTRE_FORCE_INLINE friend bool operator==(zero_terminated_string_end_iterator, const wchar_t * ptr) noexcept {
40294043
return *ptr == 0;
40304044
}
4031-
constexpr CTRE_FORCE_INLINE bool operator!=(const char * ptr) const noexcept {
4045+
constexpr CTRE_FORCE_INLINE friend bool operator!=(zero_terminated_string_end_iterator, const char * ptr) noexcept {
40324046
return *ptr != '\0';
40334047
}
4034-
constexpr CTRE_FORCE_INLINE bool operator!=(const wchar_t * ptr) const noexcept {
4048+
constexpr CTRE_FORCE_INLINE friend bool operator!=(zero_terminated_string_end_iterator, const wchar_t * ptr) noexcept {
40354049
return *ptr != 0;
40364050
}
40374051
};

0 commit comments

Comments
 (0)