Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate code #2

Open
mfeemster opened this issue Jun 18, 2015 · 0 comments
Open

Duplicate code #2

mfeemster opened this issue Jun 18, 2015 · 0 comments

Comments

@mfeemster
Copy link

The code for const function delegates causes a compilation error in VC++ 2013:

template<typename return_type, typename... params>
class Delegate<return_type(params...) const>
        : public BaseDelegate<return_type, params...>
{
    typedef BaseDelegate<return_type, params...> Base;
public:
    Delegate(void* callee, typename Base::Pointer2Function function)
        : Base(callee, function)
    { }
};

error C2953: 'Delegate<return_type(params...),>' : class template has already been defined.

Which also causes an error further down in the file:

    template<return_type(T::*Func)(params...) const>
    inline static Delegate<return_type(params...) const> CreateC(T* o)
    {
        return Delegate<return_type(params...) const>(o, &DelegateFactory::MethodCallerC<Func>);
    }

'abstract declarator' : modifiers not allowed on nonmember functions

Here is what is needed for it to fully build:

#ifndef _MSC_VER
template<typename return_type, typename... params>
class Delegate<return_type(params...) const>
        : public BaseDelegate<return_type, params...>
{
    typedef BaseDelegate<return_type, params...> Base;
public:
    Delegate(void* callee, typename Base::Pointer2Function function)
        : Base(callee, function)
    { }
};
#endif

...

#ifdef _MSC_VER
    template<return_type(T::*Func)(params...) const>
    inline static Delegate<return_type(params...)/* const*/> CreateC(T* o)
    {
        return Delegate<return_type(params...)/* const*/>(o, &DelegateFactory::MethodCallerC<Func>);
    }
#else
    template<return_type(T::*Func)(params...) const>
    inline static Delegate<return_type(params...) const> CreateC(T* o)
    {
        return Delegate<return_type(params...) const>(o, &DelegateFactory::MethodCallerC<Func>);
    }
#endif

Were you able to get this to build in Visual C++?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant