microsoft / wil

Windows Implementation Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

single_threaded_property<> doesn't work for enums?

jonwis opened this issue · comments

const auto& operator()()
{
return *this;
}

Trying to write this:

// IDL
enum FooKind { Kitten, Muffin };
runtimeclass Foo {
    FooKind Kind;
}

// c++
struct Foo : FooT<Foo> {
    single_threaded_property<FooKind> Kind;
}

Gets me:

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2664	'auto winrt::impl::detach_from<winrt::Test::FooKind>(T &&) noexcept': cannot convert argument 1 from 'const wil::single_threaded_property<winrt::Test::FooKind>' to 'T &&'    winrt\Foo.h	368	

Two potential fixes:

  1. Change the signature to T operator()()
  2. Change the method to auto operator()() { return static_cast<T>(*this); }