Fix build error with use_custom_libcxx=true on Windows

std::codecvt has a protected destructor, so it needs some extra boilerplate to
be used with std::wstring_convert.  This CL follows the example from [1].

This was working before because MSVC is nonstandard and std::codecvt::~codecvt
is public.

[1] https://en.cppreference.com/w/cpp/locale/codecvt

BUG=chromium:801780

Change-Id: Ic4b5baabcd9bfc9f60231204f050e369e79b4579
Reviewed-on: https://dawn-review.googlesource.com/c/4840
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Tom Anderson 2019-02-18 10:48:53 +00:00 committed by Commit Bot service account
parent 37b715deec
commit c1d15b1dbf

View File

@ -22,6 +22,17 @@
namespace dawn_native { namespace d3d12 {
// utility wrapper to adapt locale-bound facets for wstring/wbuffer convert
template <class Facet>
struct DeletableFacet : Facet {
template <class... Args>
DeletableFacet(Args&&... args) : Facet(std::forward<Args>(args)...) {
}
~DeletableFacet() {
}
};
Adapter::Adapter(Backend* backend, ComPtr<IDXGIAdapter1> hardwareAdapter)
: AdapterBase(backend->GetInstance(), BackendType::D3D12),
mHardwareAdapter(hardwareAdapter),
@ -32,7 +43,7 @@ namespace dawn_native { namespace d3d12 {
mPCIInfo.deviceId = adapterDesc.DeviceId;
mPCIInfo.vendorId = adapterDesc.VendorId;
std::wstring_convert<std::codecvt<wchar_t, char, std::mbstate_t>> converter(
std::wstring_convert<DeletableFacet<std::codecvt<wchar_t, char, std::mbstate_t>>> converter(
"Error converting");
mPCIInfo.name = converter.to_bytes(adapterDesc.Description);
}