Open manuel76413 opened 1 year ago
Thank you. It's in my todolist.
But, in this case, the shared_ptr is unnecessary.
If you don't want to shared the nodes, just remove the shared_ptr.
enum class type_e {
root = 0,
users = 1,
projs = 2,
};
struct Node {
type_e type;
std::string name;
std::string value;
std::list<Node> children;
};
Serialize/deserilaize shared_ptr will cost additional price. First we need check if the address is same as previous one to shared the object. Second deserialize shared_ptr may cause memory leak and we need to check it. Anyway I will try to support it later.
thanks for your reply, This library is very cute
shared_ptr可能会导致循环引用问题,这个不是很好解决吧
shared_ptr可能会导致循环引用问题,这个不是很好解决吧
shared_ptr可能会导致循环引用问题,这个不是很好解决吧
- 首先在编译期检查类型是否成环。只有类型系统成环才可能出现循环引用。
- 类型成环的情况下,要么禁止序列化这种类型,要么在反序列化时跑下dfs检测是否循环引用。 soga
I saw the struct_pack library supports many STL containers but after testing, I regretted that this library does not support the smart point of C++ 11. like shared_ptr etc.
for example, I have a tree node struct like:
enum class type_e { root = 0, users = 1, projs = 2, };
struct Node { type_e type; std::string name; std::string value; std::list<std::shared_ptr<Node>> children;
};
for now, this library cannot serialize/deserialize the above Node structure. you can reference another nonintrusive library named alpaca, which supports smart point.