Skip to content

Conversation

@sylveon
Copy link
Contributor

@sylveon sylveon commented Dec 5, 2021

Fixes #1069

Was manually tested by building and running this snippet:

// silence a clang coroutine warning caused by cppwinrt. we don't actually use coroutines here.
#define _SILENCE_CLANG_COROUTINE_MESSAGE

// std::format is hidden behind /std:c++latest due to ABI concerns right now
// but the headers don't detect Clang's -std=c++2b, so manually have them believe we are using C++23.
#define _HAS_CXX23 1

#include <format>
#include <iostream>

// required for cppwinrt to not fail building with clang
#include <guiddef.h>

#include "winrt/Windows.Foundation.h"

#pragma comment(lib, "onecore.lib")

struct stringable : winrt::implements<stringable, winrt::Windows::Foundation::IStringable>
{
    winrt::hstring ToString()
    {
        return L"a stringable object";
    }
};

int main()
{
    winrt::Windows::Foundation::IStringable obj = winrt::make<stringable>();
    std::wcout << std::format(L"This is {}", obj);
}

With clang -Icppwinrt/_build/x64/Debug -std=c++2b test.cpp

@kennykerr
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @dunhor ?

@kennykerr kennykerr merged commit 0be01db into microsoft:master Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specialization of 'std::formatter<winrt::Windows::Foundation::IStringable, wchar_t>' breaks with conformant compilers

3 participants