rapidjson::Document in std::pair
rapidjson::Document in std::pair
我收到此错误:
Undefined symbols for architecture i386:
rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >::GenericValue(rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> > const&)
当我尝试成对返回rapidjson::Document
时,此错误会跳到我身上:
typedef std::pair<rapidjson::Document, std::string> ProcessedResponseResult;
ProcessedResponseResult ProcessResponse(HttpResponse* response)
{
rapidjson::Document jsonDoc;
...
return ProcessedResponseResult(jsonDoc, std::string());
}
如果有帮助,rapidjson 是一个仅标头库。
为什么我不能退回这对?
当你构造一个ProcessedResponseResult
时,它会调用rapidjson::Document
的复制构造函数,但在文件rapidjason/document.h
中,为了防止复制rapidjson::Document
对象,它声明了一个私有复制构造函数,并且不实现它,所以这会导致链接器错误。
//! Copy constructor is not permitted.
private:
GenericValue(const GenericValue& rhs);
如果您使用 std::pair
的原因只是从函数返回 2 个值,我建议您通过引用传递jsonDoc
。
相关文章:
- 对的排序向量 (std::vector<pair<int, int>>) 按对的第一个元素搜索并更新第二个元素值
- c++:在switch中使用std::pair的可能性
- 将从std::映射中获取的std::pair引用传递给接受std::对引用的函数
- Hash for a std::pair, for use in an unordered_map
- 类模板的参数太少 "std::pair":在函数中将 std 对作为参数传递
- 如何使用 std::sort with pair and references
- 如何在给定范围内找到 std::set<pair<int、int> > 中的最大值?
- C++ vector<pair<int,int>> std::all_of() 函数问题(重定向到头文件)
- 接收std :: Pair作为参数并从支撑列表初始化中推论的模板函数
- 如何更新最近在 std::vector<pair<int, int>> 中输入的元素?
- std::pair中的template-template参数
- std::experimental::ostream_joiner and std::pair
- 如何将两个std :: vector结合到一个std :: vector与std :: pair
- 错误 C2678:二进制'==':找不到采用 'std::pair<const _Kty,_Ty>' 型左操作数的运算符
- C++错误处理-使用std::pair或std::tuple返回错误代码和函数返回的缺点
- C++ 如何打印此地图 std::map<int, pair<vector<pair<int, int>>, int>>
- 我会看到使用 std::map 而不是 vector<pair<string、string> > 的性能提升吗?
- 在 std::set 中插入对不一致(无法识别 <pair>.second)
- 将std::pair转换为具有任意数量元素的std::tuple
- 宏MOCK_METHOD传递了3个参数,但std::pair只接受了2个错误