简体   繁体   English

模板函数调用中的C ++错误:不允许输入类型名称

[英]C++ error in template function call: type name is not allowed

Diab compiler complains in line @@@ that type name is not allowed. Diab编译器在@@@行中抱怨不允许使用类型名称。

template<
    Task TASK,
    Event EVENT>
class TManager :
    public AbstractTManager,
    public common::ITManager
{
    public:
    typedef os::EManager<TASK>  tEManager;

    TManager()
    { /* ... */}

    virtual void init()
    {

        tEManager::registerCallback<
            EVENT,
            TManager, /* @@@ */
            &TManager::func>(*this);
    }

    void func()
    { /* ... */}
}

In EManager registerCallback is defined in following way: 在EManager中,registerCallback的定义方式如下:

template<TType task>
class EManager
{
public:
    template<
        EType event,
        typename e_listener,
        void (e_listener::*TMethod)()
        >
    static void registerCallback(e_listener& listener)
    {
        /* ... */
    }
}

The second template argument is e_listener with keyword typename so I don't know why it reports problem. 第二个模板参数是带有关键字typename的e_listener,所以我不知道为什么它报告问题。 Did I miss something? 我错过了什么? Thank you for help in advance. 预先感谢您的帮助。

You should add template : 您应该添加template

tEManager::template registerCallback<
        EVENT,
        TManager,
        &TManager::func>(*this);

Thank you Jarod42 and chris. 谢谢Jarod42和chris。 It works! 有用! I missed this really valuable topic which includes solution in chapter "The template keyword": Where and why do I have to put the "template" and "typename" keywords? 我错过了这个非常有价值的主题,其中包括“模板关键字”一章中的解决方案: 为什么必须在何处以及为什么放置“模板”和“类型名”关键字?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM