mercredi 12 août 2020

Providing a default value as function for a template

When i use following as say Event<void()> it works fine. But now i like to have default template value so i change following to template<class _Fty = void()> so i can have Event<> aEvent. But it seem to fail with bunch of errors.

template<class _Fty>
struct Event final {
    typedef std::function<_Fty> listener_type;
    ...
}

Can anyone suggest how can accomplish what i want as describe above?

error C2027: use of undefined type 'std::_Get_function_impl<_Fty>'
        with
        [
            _Fty=void (__cdecl *)(void)
        ]
C:\PROGRA~2\MIB055~1\2017\Professional\VC\Tools\MSVC\14.16.27023\include\functional(1479): note: see declaration of 'std::_Get_function_impl<_Fty>'
        with
        [
            _Fty=void (__cdecl *)(void)
        ]

Aucun commentaire:

Enregistrer un commentaire