Hi, I have a problem with template in which I use QMap:
Qt Code:
  1. template
  2. <
  3. class IdentifierType,
  4. class BytesToRead
  5. >
  6. class CommandHandler : public Command
  7. {
  8. public:
  9. explicit CommandHandler();
  10. ~CommandHandler();
  11.  
  12. static bool registerCommand(const IdentifierType& identifier, Command* ptrToObject);
  13. static bool unregisterCommand(const IdentifierType& identifier);
  14. QPair<ResponseType::type, QByteArray> handleMessage(QByteArray* datagramPtr);
  15.  
  16. private:
  17. static QMap<IdentifierType, Command*> _associations;
  18. };
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. template <class IdentifierType, class BytesToRead>
  2. bool
  3. CommandHandler<IdentifierType, BytesToRead>
  4. ::registerCommand(const IdentifierType& identifier, Command* ptrToObject)
  5. {
  6. if(_associations.contains(identifier))
  7. return 0;
  8. else
  9. {
  10. _associations.insert(identifier, ptrToObject);
  11. return 1;
  12. }
  13. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. namespace TransportLayerType {
  2. enum type{
  3. V1 = 1
  4. };
  5. }
  6.  
  7. typedef CommandHandler<TransportLayerType::type, quint8> TransportLayerHandler;
To copy to clipboard, switch view to plain text mode 
And when I try to do this:
Qt Code:
  1. TransportLayerHandler::registerCommand(TransportLayerType::V1, new TransportLayerV1());
To copy to clipboard, switch view to plain text mode 
I get:
undefined reference to `CommandHandler<TransportLayerType::type, unsigned char>::_associations'
Do you have any ideas?

Thanks for help, Marcin.