[struct_pack] 是否支持智能指针 #814
Replies: 8 comments
-
这个测试代码不完整吧。 std::shared_ptr y = std::make_shared(); 这行代码编译不过的。 把没有编译错误的测试代码发出来。 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
``
|
Beta Was this translation helpful? Give feedback.
-
另外struct_pack 只支持了std::unique_ptr 暂时还不支持std::shared_ptr |
Beta Was this translation helpful? Give feedback.
-
c++17怎么没这个问题呢 |
Beta Was this translation helpful? Give feedback.
-
不支持std::shared_ptr, 你说的没这个问题有测试代码吗? |
Beta Was this translation helpful? Give feedback.
-
有,还是同一个测试代码呀,上面的代码,你用c++17,c++20编译就直到了 |
Beta Was this translation helpful? Give feedback.
-
我看一下,按理来说不应该编译通过。目前还没支持shared_ptr。就算C++17可以序列化,反序列化也应该失败。 |
Beta Was this translation helpful? Give feedback.
-
我写了个小测试:
std::shared_ptr<int> y = std::make_shared<int>(); auto z = struct_pack::serialize< std::vector<uint8_t>>( y);
报错信息是:
error: cannot decompose inaccessible member ‘std::__shared_ptr<int, __gnu_cxx::_S_atomic>::_M_ptr’ of ‘std::__shared_ptr<int, __gnu_cxx::_S_atomic>’
1212 | auto &&[a1, a2] = object;
| ^~~~~~~~
我们的业务需要序列化
std::shared_ptr<vector<std::shared_ptr<int>>>
Beta Was this translation helpful? Give feedback.
All reactions