diff --git a/strings/base_reference_produce.h b/strings/base_reference_produce.h index 31477b8a0..4ad39c5b9 100644 --- a/strings/base_reference_produce.h +++ b/strings/base_reference_produce.h @@ -318,7 +318,7 @@ WINRT_EXPORT namespace winrt } } - template + template , int> = 0> hstring unbox_value_or(Windows::Foundation::IInspectable const& value, param::hstring const& default_value) { if (value) diff --git a/test/old_tests/UnitTests/Boxing2.cpp b/test/old_tests/UnitTests/Boxing2.cpp index 1c43d0402..3b7c85d6b 100644 --- a/test/old_tests/UnitTests/Boxing2.cpp +++ b/test/old_tests/UnitTests/Boxing2.cpp @@ -214,4 +214,10 @@ TEST_CASE("Boxing") REQUIRE(unbox_value_or(box_value(static_cast(UnsignedEnum::Second)), UnsignedEnum::First) == UnsignedEnum::First); REQUIRE(unbox_value_or(box_value(static_cast(UnsignedEnum::Second)), UnsignedEnum::First) == UnsignedEnum::First); } + + { + // Test some cases where the compiler has to choose between multiple overloads. + REQUIRE(unbox_value_or(nullptr, {}) == IInspectable{}); + REQUIRE(unbox_value_or(nullptr, hstring{}) == hstring{}); + } }