I want to write something to share memory,
pAttr is the share memory address.
The template function as below,
but it does not pass the compile.
template <typename Container>
int ShareMemMgn::writeContainerToShareMemMap(void* pAttr, Container& oData)
{
typename Container::mapped_type T;
(T*)(pElem) = (T *)(pAttr); //compile errror
/*
share_mem_mgn.cpp:545: error: expected primary-expression before ‘)’ token
share_mem_mgn.cpp:545: error: ‘pElem’ was not declared in this scope
share_mem_mgn.cpp:545: error: expected primary-expression before ‘)’ token
*/
for(typename Container::iterator it = oData.begin();
it != oData.end(); ++it)
{
memcpy(pElem, (&(it->second)), sizeof(typename Container::mapped_type));
++pElem;
}
return 0;
}
How to get the maped type pointer?
Could anyone help me?
Thanks a lot.
You could also do this
If you are using only a Map.