how do i serialize list variable of type <boost::shared_ptr<void *>>

余生颓废 提交于 2019-12-25 03:47:20

问题


I'm really not sure how do i serialize a list variable of type boost::shared_ptr <void *> inside a class or struct. Generally, i would go with same method that we generally use like

struct A
{
    std::list<boost::shared_ptr<void *>> mdb;
}

template<class Archive>
void serialize(Archive &d,const unsigned int version)
{
      d & mdb;  // not sure that this would work
}

while compiling it does not give error but does not serialize at my end.


回答1:


You don't. In all likelihood, the void* is

  • a HANDLE (for some native API); you can serialize this only if the API has enough identifying information to reconstruct the handle on load
  • a type pun for something else (this would be silly, just have the real type there, then)


来源:https://stackoverflow.com/questions/23457722/how-do-i-serialize-list-variable-of-type-boostshared-ptrvoid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!