Skip navigation.
Home
The QNX Community Portal

View topic - map with template class

map with template class

Discussions, suggestions, requests about this website.

map with template class

Postby Puja » Wed Feb 10, 2010 11:24 am

I am using map to store the class pointer and function pointers, The same code complies very fine with Visual Studio 2005 but not in Momentics(Qnx 6.4.0)

Following code gives error for iterator.

Code Line: g_ClassFuncPointerTDMap::iterator it1;

Error : "type 'std::map<TClass*, void (TClass::*)(unsigned int, unsigned int), std::less<TClass*>, std::allocator<std::pair<TClass* const, void (TClass::*)(unsigned int, unsigned int)> > >' is not derived from type 'Functor<TClass>' aaa Functor.h"


Could you please let me know the solution.

#ifndef FUNCTOR_H_
#define FUNCTOR_H_

#include <iostream>
#include <string>
#include <map>

using namespace std;

template <class TClass>
class Functor
{
public:

typedef void (TClass::*m_pFunctionPointer)(unsigned int,unsigned int);
typedef map<TClass*, m_pFunctionPointer> g_ClassFuncPointerTDMap;
typedef map<int, g_ClassFuncPointerTDMap > g_SignalClassFPTDMap;


static g_ClassFuncPointerTDMap g_ClassFuncPointerMap;
static g_SignalClassFPTDMap g_SignalClassFPMap;

g_ClassFuncPointerTDMap::iterator it1;
}
#endif
Puja
Active Member
 
Posts: 14
Joined: Wed Aug 26, 2009 6:40 am

RE: map with template class

Postby mario » Wed Feb 10, 2010 1:31 pm

Sorry but VC is NOT a reference... This is not related to QNX but rather to GCC.

Try

typedef typename map<TClass*, m_pFunctionPointer>::iterator g_ClassFuncPointerTDMapIt;

g_ClassFuncPointerTDMapIt it1;

http://www.parashift.com/c++-faq-lite/t ... #faq-35.18
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am


Return to OpenQNX Site

Who is online

Users browsing this forum: No registered users and 1 guest

cron