如何解决用于列表构造的 openapi-generator 的“cpp-restbed-server”生成器的编译错误
通过以下方式为 openAPI 规范生成 cpp 代码:
./run-in-docker.sh generate -i
类型为 std::shared_ptr 的 std::vector 的生成构造存在问题。
示例:
std::vectorstd::shared_ptr
编译错误在以下部分抛出:
if (pt.get_child_optional("guamiList")) {
for (const auto &childTree : pt.get_child("guamiList")) {
m_GuamiList.emplace_back(childTree.second.data());
}
}
编译错误:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33:0,from /usr/include/c++/7/bits/allocator.h:46,from /usr/include/c++/7/string:41,from /root/openapi-generator/out/cpp-restbed-server/TS29510_Nnrf_NFManagement/March26/model/N2InterfaceAmfInfo.h:24,from /root/openapi-generator/out/cpp-restbed-server/TS29510_Nnrf_NFManagement/March26/model/AmfInfo.h:24,from /root/openapi-generator/out/cpp-restbed-server/TS29510_Nnrf_NFManagement/March26/model/AmfInfo.cpp:15:
/usr/include/c++/7/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*,_Args&& ...) [with _Up = std::shared_ptr<org::openapitools::server::model::Guami>; _Args = {const std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char> >&}; _Tp = std::shared_ptr<org::openapitools::server::model::Guami>]’:
/usr/include/c++/7/bits/alloc_traits.h:475:4: required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&,_Up*,std::allocator<char> >&}; _Tp = std::shared_ptr<org::openapitools::server::model::Guami>; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::shared_ptr<org::openapitools::server::model::Guami> >]’
/usr/include/c++/7/bits/vector.tcc:100:30: required from ‘std::vector<_Tp,_Alloc>::reference std::vector<_Tp,_Alloc>::emplace_back(_Args&& ...) [with _Args = {const std::__cxx11::basic_string<char,std::allocator<char> >&}; _Tp = std::shared_ptr<org::openapitools::server::model::Guami>; _Alloc = std::allocator<std::shared_ptr<org::openapitools::server::model::Guami> >; std::vector<_Tp,_Alloc>::reference = std::shared_ptr<org::openapitools::server::model::Guami>&]’
/root/openapi-generator/out/cpp-restbed-server/TS29510_Nnrf_NFManagement/March26/model/AmfInfo.cpp:127:52: required from here
/usr/include/c++/7/ext/new_allocator.h:136:4: error: no matching function for call to ‘std::shared_ptr<org::openapitools::server::model::Guami>::shared_ptr(const std::__cxx11::basic_string<char>&)’
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
对不起,如果之前已经讨论过,建议解决方案/修复,即使是临时修复。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。