Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Windows通知:依赖模板名称的使用_C++_Windows_Templates_Notifications - Fatal编程技术网

C++ Windows通知:依赖模板名称的使用

C++ Windows通知:依赖模板名称的使用,c++,windows,templates,notifications,C++,Windows,Templates,Notifications,我当前正在尝试为Windows 10本机通知创建回调。我添加通知的代码如下所示: notification->add_Dismissed( Callback<Implements<RuntimeClassFlags<ClassicCom>, ITypedEventHandler<ToastNotification*, ToastDismissedEventArgs*>>>( [eventHandler, expira

我当前正在尝试为Windows 10本机通知创建回调。我添加通知的代码如下所示:

notification->add_Dismissed(
    Callback<Implements<RuntimeClassFlags<ClassicCom>,
    ITypedEventHandler<ToastNotification*, ToastDismissedEventArgs*>>>(

    [eventHandler, expirationTime](IToastNotification*, IToastDismissedEventArgs* e) {

        ToastDismissalReason reason;
        if (SUCCEEDED(e->get_Reason(&reason))) {
            if (reason == ToastDismissalReason_UserCanceled &&
                expirationTime &&
                MyDateTime::Now() >= expirationTime
            ){
                reason = ToastDismissalReason_TimedOut;
            }

            eventHandler->toastDismissed(static_cast<IWinToastHandler::WinToastDismissalReason>(reason));
        }

        return S_OK;
}).Get(), &dismissedToken);
遵循错误消息引用的代码:

// Construct a COM/WinRT delegate (an object with an Invoke() method) from a lambda.
// Check the return from this function for null to detect out of memory (E_OUTOFMEMORY) failure case.
template<typename TDelegateInterface, typename TLambda>
ComPtr<typename Details::DelegateArgTraitsHelper<TDelegateInterface>::Interface> Callback(TLambda&& callback) throw()
{
    using DelegateHelper = Details::DelegateArgTraitsHelper<TDelegateInterface>;
    return DelegateHelper::Traits::Callback<TDelegateInterface, typename DelegateHelper::Interface>(Details::Forward<TLambda>(callback));
}

// Construct a COM/WinRT delegate, an object with an Invoke() method, from a raw function.
template<typename TDelegateInterface, typename TFunc> ComPtr<typename Details::DelegateArgTraitsHelper<TDelegateInterface>::Interface> Callback(_In_ TFunc* callback) throw()
{
    using DelegateHelper = Details::DelegateArgTraitsHelper<TDelegateInterface>;
    return DelegateHelper::Traits::Callback<TDelegateInterface, typename DelegateHelper::Interface>(
    [=](auto&& ...args) {
        return callback(Details::Forward<decltype(args)>(args)...);
    });
}
老实说,我不知道怎么了。自上次更新以来,据我所知,这段代码一直在工作。你能告诉我解决办法吗

我知道它与依赖模板名称有关。但我不知道代码的哪一部分是错误的——如果是winrt中的某种输入错误,或者他们最近更改了某些内容,我必须调整我的代码

谢谢您的建议。

正如所指出的,他们可能做了一些更改,现在需要关键字模板作为从属模板

如果有人想知道,这是event.h中的新代码,它似乎在工作:

// Construct a COM/WinRT delegate (an object with an Invoke() method) from a lambda.
// Check the return from this function for null to detect out of memory (E_OUTOFMEMORY) failure case.
template<typename TDelegateInterface, typename TLambda>
ComPtr<typename Details::DelegateArgTraitsHelper<TDelegateInterface>::Interface> Callback(TLambda&& callback) throw()
{
    using DelegateHelper = Details::DelegateArgTraitsHelper<TDelegateInterface>;
    return DelegateHelper::Traits::template Callback<TDelegateInterface, typename DelegateHelper::Interface>(Details::Forward<TLambda>(callback));
}

// Construct a COM/WinRT delegate, an object with an Invoke() method, from a raw function.
template<typename TDelegateInterface, typename TFunc>
ComPtr<typename Details::DelegateArgTraitsHelper<TDelegateInterface>::Interface> Callback(_In_ TFunc* callback) throw()
{
    using DelegateHelper = Details::DelegateArgTraitsHelper<TDelegateInterface>;
    return DelegateHelper::Traits::template Callback<TDelegateInterface, typename DelegateHelper::Interface>(
    [=](auto&& ...args)
    {
        return callback(Details::Forward<decltype(args)>(args)...);
    });
}

他们更改了规则,不再接受没有模板的代码作为依赖模板。必须修复的是event.h。@Evg谢谢,你说得对!
// Construct a COM/WinRT delegate (an object with an Invoke() method) from a lambda.
// Check the return from this function for null to detect out of memory (E_OUTOFMEMORY) failure case.
template<typename TDelegateInterface, typename TLambda>
ComPtr<typename Details::DelegateArgTraitsHelper<TDelegateInterface>::Interface> Callback(TLambda&& callback) throw()
{
    using DelegateHelper = Details::DelegateArgTraitsHelper<TDelegateInterface>;
    return DelegateHelper::Traits::template Callback<TDelegateInterface, typename DelegateHelper::Interface>(Details::Forward<TLambda>(callback));
}

// Construct a COM/WinRT delegate, an object with an Invoke() method, from a raw function.
template<typename TDelegateInterface, typename TFunc>
ComPtr<typename Details::DelegateArgTraitsHelper<TDelegateInterface>::Interface> Callback(_In_ TFunc* callback) throw()
{
    using DelegateHelper = Details::DelegateArgTraitsHelper<TDelegateInterface>;
    return DelegateHelper::Traits::template Callback<TDelegateInterface, typename DelegateHelper::Interface>(
    [=](auto&& ...args)
    {
        return callback(Details::Forward<decltype(args)>(args)...);
    });
}