kennykerr / modern

Modern C++ for the Windows Runtime
https://moderncpp.com/
MIT License
295 stars 36 forks source link

Implements Class template method "FindInterface" and const #4

Closed jamespack closed 9 years ago

jamespack commented 9 years ago

Not sure if this is an issue but I have been working through your new course Windows Runtime Internals on Pluralsight and I grabbed a copy of the implements class template from here to use.

When I compile the standard c++ project in the 'Core Apps in Standard C++' module with the class template I get the following compiler error:

error C2440: 'static_cast': cannot convert from 'const Modern::Implements<ABI::Windows::ApplicationModel::Core::IFrameworkView,ABI::Windows::ApplicationModel::Core::IFrameworkViewSource> *const ' to 'ABI::Windows::ApplicationModel::Core::IFrameworkViewSource *'

When I double click the error it drops me in this function from the class template:

template <typename First, typename ... Rest>
void * FindInterface(GUID const & id) const noexcept
{
    if (id == __uuidof(First))
    {
        return static_cast<First *>(this);
    }
    return FindInterface<Rest ...>(id);
}

If I remove the const from the method the project builds without error.

kennykerr commented 9 years ago

Thanks James! That is a known bug in the version of Implements that shipped with the initial release of Modern. It has already been fixed and will be updated on GitHub in the next day or two. Thanks for pointing it out though. Glad you were able to figure it out!

kennykerr commented 9 years ago

This has been fixed as of Modern v1.25.