diff --git a/cppwinrt/code_writers.h b/cppwinrt/code_writers.h index 385219bb6..51ecc63d6 100644 --- a/cppwinrt/code_writers.h +++ b/cppwinrt/code_writers.h @@ -2858,28 +2858,12 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable field.first); } - static void write_struct_equality(writer& w, std::vector> const& fields) - { - for (std::size_t i = 0; i != fields.size(); ++i) - { - w.write(" left.% == right.%", fields[i].first, fields[i].first); - - if (i + 1 != fields.size()) - { - w.write(" &&"); - } - } - } - static bool write_structs(writer& w, std::vector const& types) { auto format = R"( struct % { -% }; - inline bool operator==(% const& left, % const& right)% - { - return%; - } +% bool operator==(% const& other) const% = default; + }; )"; if (types.empty()) @@ -2962,9 +2946,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable name, bind_each(type.fields), name, - name, - is_noexcept, - bind(type.fields)); + is_noexcept); for (auto&& field : type.fields) { diff --git a/cppwinrt/type_writers.h b/cppwinrt/type_writers.h index df17450f1..bb56c5724 100644 --- a/cppwinrt/type_writers.h +++ b/cppwinrt/type_writers.h @@ -42,32 +42,29 @@ namespace cppwinrt name_space = type_namespace; name = type_name; } - }; - bool operator==(type_name const& left, type_name const& right) - { - return left.name == right.name && left.name_space == right.name_space; - } + bool operator==(type_name const& other) const noexcept = default; - bool operator==(type_name const& left, std::string_view const& right) - { - if (left.name.size() + 1 + left.name_space.size() != right.size()) + bool operator==(std::string_view const& right) const noexcept { - return false; - } + if (name.size() + 1 + name_space.size() != right.size()) + { + return false; + } - if (right[left.name_space.size()] != '.') - { - return false; - } + if (right[name_space.size()] != '.') + { + return false; + } - if (0 != right.compare(left.name_space.size() + 1, left.name.size(), left.name)) - { - return false; - } + if (0 != right.compare(name_space.size() + 1, name.size(), name)) + { + return false; + } - return 0 == right.compare(0, left.name_space.size(), left.name_space); - } + return 0 == right.compare(0, name_space.size(), name_space); + } + }; static auto remove_tick(std::string_view const& name) { diff --git a/strings/base_events.h b/strings/base_events.h index b307823ad..88e51acbe 100644 --- a/strings/base_events.h +++ b/strings/base_events.h @@ -9,12 +9,9 @@ WINRT_EXPORT namespace winrt { return value != 0; } - }; - inline bool operator==(event_token const& left, event_token const& right) noexcept - { - return left.value == right.value; - } + bool operator==(event_token const& other) const noexcept = default; + }; struct auto_revoke_t {}; inline constexpr auto_revoke_t auto_revoke{}; diff --git a/strings/base_string.h b/strings/base_string.h index a11f725e2..98b85590e 100644 --- a/strings/base_string.h +++ b/strings/base_string.h @@ -233,7 +233,7 @@ WINRT_EXPORT namespace winrt friend bool operator==(hstring const& left, std::wstring const& right) noexcept { - return std::wstring_view(left) == right; + return std::wstring_view(left) == std::wstring_view(right); } friend std::strong_ordering operator<=>(hstring const& left, std::wstring const& right) noexcept @@ -241,19 +241,9 @@ WINRT_EXPORT namespace winrt return std::wstring_view(left) <=> std::wstring_view(right); } - friend bool operator==(std::wstring const& left, hstring const& right) noexcept - { - return left == std::wstring_view(right); - } - - friend std::strong_ordering operator<=>(std::wstring const& left, hstring const& right) noexcept - { - return std::wstring_view(left) <=> std::wstring_view(right); - } - friend bool operator==(hstring const& left, wchar_t const* right) noexcept { - return std::wstring_view(left) == right; + return std::wstring_view(left) == std::wstring_view(right); } friend std::strong_ordering operator<=>(hstring const& left, wchar_t const* right) noexcept @@ -261,20 +251,8 @@ WINRT_EXPORT namespace winrt return std::wstring_view(left) <=> std::wstring_view(right); } - friend bool operator==(wchar_t const* left, hstring const& right) noexcept - { - return left == std::wstring_view(right); - } - - friend std::strong_ordering operator<=>(wchar_t const* left, hstring const& right) noexcept - { - return std::wstring_view(left) <=> std::wstring_view(right); - } - friend bool operator==(hstring const&, std::nullptr_t) = delete; - friend bool operator==(std::nullptr_t, hstring const&) = delete; friend std::strong_ordering operator<=>(hstring const&, std::nullptr_t) = delete; - friend std::strong_ordering operator<=>(std::nullptr_t, hstring const&) = delete; void clear() noexcept { diff --git a/strings/base_string_operators.h b/strings/base_string_operators.h index aa9c71c95..7e237866d 100644 --- a/strings/base_string_operators.h +++ b/strings/base_string_operators.h @@ -1,8 +1,3 @@ - -WINRT_EXPORT namespace winrt -{ -} - WINRT_EXPORT namespace winrt::impl { inline hstring concat_hstring(std::wstring_view const& left, std::wstring_view const& right)