怎么做模板Map和函数?
#ifndef __MapWrapper_H__
#define __MapWrapper_H__
#if (defined(WIN32) || defined(_WIN32_WCE))
#pragma warning(disable:4786)
#include "WTYPES.H" //HANDLE
#else
#include <pthread.h> //multiple thread
#endif
#include <map>
template <class T>
//typedef std::map<T, void*> MAPObj;
//template <class Type>
class CMapWrapper
{
public:
CMapWrapper();
virtual ~CMapWrapper();
bool InsertToMap(T id, void* pObj);
bool ReplaceToMap(T id, void* pObj);
bool IsInMap(T id);
bool RemoveObjFrmMap(T id);
void* GetNextObj(bool bFirst=false);
void* FindObjVidID(T id);
private:
//MAPObj m_ObjMap;
typename std::map<T,void*> m_ObjMap;
#if (defined(WIN32) || defined(_WIN32_WCE))
HANDLE m_hMapMutex;
#else
pthread_mutex_t m_data_mutex;
#endif
};
#endif
#define __MapWrapper_H__
#if (defined(WIN32) || defined(_WIN32_WCE))
#pragma warning(disable:4786)
#include "WTYPES.H" //HANDLE
#else
#include <pthread.h> //multiple thread
#endif
#include <map>
template <class T>
//typedef std::map<T, void*> MAPObj;
//template <class Type>
class CMapWrapper
{
public:
CMapWrapper();
virtual ~CMapWrapper();
bool InsertToMap(T id, void* pObj);
bool ReplaceToMap(T id, void* pObj);
bool IsInMap(T id);
bool RemoveObjFrmMap(T id);
void* GetNextObj(bool bFirst=false);
void* FindObjVidID(T id);
private:
//MAPObj m_ObjMap;
typename std::map<T,void*> m_ObjMap;
#if (defined(WIN32) || defined(_WIN32_WCE))
HANDLE m_hMapMutex;
#else
pthread_mutex_t m_data_mutex;
#endif
};
#endif
...全文
相关推荐
再见,BEGIN_MSG_MAP!
使用Boost.MPL库替换BEGIN_MSG_MAP宏。
VC/MFC加载google map
VC/MFC加载google map 可以运行 VC/MFC加载google map 可以运行
freemaker学习教程
关于freemaker遍历map,因为他会自动把map给遍历,所以你需要通过key来遍历,直接使用templete.proces()方法中的map是无效的
C++标准模板库使用
c++ 模板库 neusoft公司的培训教程
Python建立Map写Excel表实例解析
主要介绍了Python建立Map写Excel表实例解析,具有一定借鉴价值,需要的朋友可以参考下


