1

Not sure if this is a bug in MSVC 2013 ultimate, but it works fine in 2015 community. Declaration: https://github.com/dtmoodie/MetaObject/blob/master/include/MetaObject/Signals/TypedSignal.hpp

class IMetaObject;
class Context;
class Connection;
template<class Sig> class TypedSignalRelay;
template<class Sig> class TypedSignal{};
template<class...T> class MO_EXPORTS TypedSignal<void(T...)> : public ISignal
{
    std::shared_ptr<Connection> Connect(ISlot* slot);
    std::shared_ptr<Connection> Connect(std::shared_ptr<ISignalRelay>& relay);
    std::shared_ptr<Connection> Connect(std::shared_ptr<TypedSignalRelay<void(T...)>>& relay);
};

template<class R, class...T> class MO_EXPORTS TypedSignal<R(T...)> : public ISignal
{
    std::shared_ptr<Connection> Connect(ISlot* slot);
    std::shared_ptr<Connection> Connect(std::shared_ptr<ISignalRelay>& relay);
    std::shared_ptr<Connection> Connect(std::shared_ptr<TypedSignalRelay<R(T...)>>& relay);
};

Definition: https://github.com/dtmoodie/MetaObject/blob/master/include/MetaObject/Signals/detail/TypedSignalImpl.hpp

------------- Return value specialization ---------------------

template<class R, class...T>
std::shared_ptr<Connection> TypedSignal<R(T...)>::Connect(ISlot* slot)
{
    return slot->Connect(this);
}

template<class R, class...T>
std::shared_ptr<Connection> TypedSignal<R(T...)>::Connect(std::shared_ptr<ISignalRelay>& relay)
{
    ...
}

template<class R, class...T>
std::shared_ptr<Connection> TypedSignal<R(T...)>::Connect(std::shared_ptr<TypedSignalRelay<R(T...)>>& relay)
{
    ....
}

------- void return specialization -------------

template<class...T>
std::shared_ptr<Connection> TypedSignal<void(T...)>::Connect(ISlot* slot)
{
    return slot->Connect(this);
}

template<class...T>
std::shared_ptr<Connection> TypedSignal<void(T...)>::Connect(std::shared_ptr<ISignalRelay>& relay)
{
    ...
}

template<class...T>
std::shared_ptr<Connection> TypedSignal<void(T...)>::Connect(std::shared_ptr<TypedSignalRelay<void(T...)>>& relay)
{
    ...
}

Gives this error on 2013, but no complaints on 2015:

4>e:\code\metaobject\include\metaobject\signals\detail/TypedSignalImpl.hpp(77): error C2244: 'mo::TypedSignal<R(T...)>::Connect' : unable to match function definition to an existing declaration
4>          definition
4>          'std::shared_ptr<mo::Connection> mo::TypedSignal<R(T...)>::Connect(std::shared_ptr<mo::TypedSignalRelay<R(T...)>> &)'
4>          existing declarations
4>          'std::shared_ptr<mo::Connection> mo::TypedSignal<R(T...)>::Connect(std::shared_ptr<mo::TypedSignalRelay<R(T...)>> &)'
4>          'std::shared_ptr<mo::Connection> mo::TypedSignal<R(T...)>::Connect(std::shared_ptr<mo::ISignalRelay> &)'
4>          'std::shared_ptr<mo::Connection> mo::TypedSignal<R(T...)>::Connect(mo::ISlot *)'

[EDITED] Added complete example and links to original source.

Daniel Moodie
  • 357
  • 1
  • 10
  • 1
    Please post a [mcve] so that others can try the code on differing compilers and give the proper advice (which is more than likely going to be that VS2013 is obsolete). – PaulMcKenzie Sep 17 '16 at 04:05
  • 1
    this is pretty clear. You have tried to define a member function of a partial specialization ` TypedSignal`, but you have no such partial specialzation, hence the error. – Johannes Schaub - litb Sep 17 '16 at 09:24

0 Answers0