diff --git a/strings/base_reference_produce.h b/strings/base_reference_produce.h index 1965efc7a..8228cbc4c 100644 --- a/strings/base_reference_produce.h +++ b/strings/base_reference_produce.h @@ -397,7 +397,35 @@ namespace winrt::impl static auto make(array_view const& value) { return Windows::Foundation::PropertyValue::CreateRectArray(value); } using itf = Windows::Foundation::IReferenceArray; }; +} + +WINRT_EXPORT namespace winrt::Windows::Foundation +{ + template + bool operator==(IReference const& left, IReference const& right) + { + if (get_abi(left) == get_abi(right)) + { + return true; + } + + if (!left || !right) + { + return false; + } + return left.Value() == right.Value(); + } + + template + bool operator!=(IReference const& left, IReference const& right) + { + return !(left == right); + } +} + +namespace winrt::impl +{ template T unbox_value_type(From&& value) { diff --git a/strings/base_reference_produce_1.h b/strings/base_reference_produce_1.h index 7c5143821..0eb9b4b70 100644 --- a/strings/base_reference_produce_1.h +++ b/strings/base_reference_produce_1.h @@ -2,24 +2,8 @@ WINRT_EXPORT namespace winrt::Windows::Foundation { template - bool operator==(IReference const& left, IReference const& right) - { - if (get_abi(left) == get_abi(right)) - { - return true; - } - - if (!left || !right) - { - return false; - } - - return left.Value() == right.Value(); - } + bool operator==(IReference const& left, IReference const& right); template - bool operator!=(IReference const& left, IReference const& right) - { - return !(left == right); - } + bool operator!=(IReference const& left, IReference const& right); } diff --git a/test/test_component_no_pch/test_component_no_pch.idl b/test/test_component_no_pch/test_component_no_pch.idl index 11e5cbebc..b576313c8 100644 --- a/test/test_component_no_pch/test_component_no_pch.idl +++ b/test/test_component_no_pch/test_component_no_pch.idl @@ -33,4 +33,11 @@ namespace test_component_no_pch Int32 Second; }; } + + // This structure verifies that the structure can at least be declared + // (but perhaps not meaningfully consumed) without having first included Windows.Foundation.h. + struct StructWithReference + { + Windows.Foundation.IReference OptionalValue; + }; }