Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions cppwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2858,28 +2858,12 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
field.first);
}

static void write_struct_equality(writer& w, std::vector<std::pair<std::string_view, std::string>> 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<TypeDef> const& types)
{
auto format = R"( struct %
{
% };
inline bool operator==(% const& left, % const& right)%
{
return%;
}
% bool operator==(% const& other) const% = default;
};
)";

if (types.empty())
Expand Down Expand Up @@ -2962,9 +2946,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
name,
bind_each<write_struct_field>(type.fields),
name,
name,
is_noexcept,
bind<write_struct_equality>(type.fields));
is_noexcept);

for (auto&& field : type.fields)
{
Expand Down
37 changes: 17 additions & 20 deletions cppwinrt/type_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 2 additions & 5 deletions strings/base_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
26 changes: 2 additions & 24 deletions strings/base_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,48 +233,26 @@ 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
{
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
{
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
{
Expand Down
5 changes: 0 additions & 5 deletions strings/base_string_operators.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down