在 2024-10-07 16:06, Biswapriyo Nath 写道:
From 80b827bfdf231bd49f9fe1d392b06a506a98a568 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath<nathbap...@gmail.com> Date: Mon, 7 Oct 2024 08:03:43 +0000 Subject: [PATCH] headers: Add more Set member template in HString classThis fixes the following compiler error with gecko. mozilla-unified/widget/windows/ToastNotification.cpp:832:14: error: no matching member function for call to 'Set' 832 | hr = aumid.Set(mAumid.ref().get()); | ~~~~~~^~~ corewrappers.h:58:25: note: candidate function not viable: no known conversion from 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t') to 'const HSTRING' (aka 'HSTRING__ *const') for 1st argument corewrappers.h:53:25: note: candidate function not viable: requires 2 arguments, but 1 was provided Signed-off-by: Biswapriyo Nath<nathbap...@gmail.com> --- .../include/wrl/wrappers/corewrappers.h | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
Thanks. Pushed with a little change:`std::is_convertible<T, const wchar_t*>` is equivalent to `std::is_convertible<T&&, const wchar_t*>` so it's not strictly the same with the `static_cast` below; I have changed it to `std::is_convertible<const T&, const wchar_t*>`.
And I don't know why Microsoft decided to reinvent `EnableIf` and use a compiler intrinsic like that. There may be reasons that they don't want to (or can't) use standard C++ headers. If that's the reason, please let me know.
Without use of <type_traits> this can be implemented as ``` namespace Microsoft { namespace WRL { namespace Details { struct Dummy; Dummy convert_to_const_wchar_p_and_return_dummy(const wchar_t*) noexcept; template<typename T> T&& declval() noexcept; } namespace Wrappers { class HString { ... ... template<typename T> HRESULT Set( const T& str, decltype( ::Microsoft::WRL::Details::convert_to_const_wchar_p_and_return_dummy( ::Microsoft::WRL::Details::declval<const T&>()) ) /* no name */ = ::Microsoft::WRL::Details::Dummy()) noexcept { ... ... } ... ... }; } ``` -- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public