ORM-Lite icon indicating copy to clipboard operation
ORM-Lite copied to clipboard

error: C2664, Cannot convert argument 2 from "T" to "const std::string &"

Open kasonyin opened this issue 3 years ago • 1 comments

compiler:MSVC 16.9.31205.134 (amd64) version:master

orm-lite\ormlite.h:438: error: C2664: “bool BOT_ORM_Impl::SerializationHelper::Serialize(std::ostream &,const std::string &)”: 无法将参数 2 从“T”转换为“const std::string &” with [ T=int ] orm-lite\ormlite.h:438: 原因如下: 无法从“T”转换为“const std::string” with [ T=int ] orm-lite\ormlite.h:438: 无构造函数可以接受源类型,或构造函数重载决策不明确 orm-lite\ormlite.h:231: 参见“BOT_ORM_Impl::SerializationHelper::Serialize”的声明 orm-lite\ormlite.h:435: 在编译 类 模板 成员函数“BOT_ORM::Expression::SetExpr BOT_ORM::Expression::NullableField::operator =(T)”时 with [ T=int ] orm-lite\sample.cpp:327: 查看对正在编译的函数 模板 实例化“BOT_ORM::Expression::SetExpr BOT_ORM::Expression::NullableField::operator =(T)”的引用 with [ T=int ] orm-lite\sample.cpp:280: 查看对正在编译的 类 模板 实例化“BOT_ORM::Expression::NullableField”的引用

请问有遇到过类似的问题吗

kasonyin avatar May 08 '21 08:05 kasonyin

compiler:MSVC 16.9.31205.134 (amd64) version:master

orm-lite\ormlite.h:438: error: C2664: “bool BOT_ORM_Impl::SerializationHelper::Serialize(std::ostream &,const std::string &)”: 无法将参数 2 从“T”转换为“const std::string &” with [ T=int ] orm-lite\ormlite.h:438: 原因如下: 无法从“T”转换为“const std::string” with [ T=int ] orm-lite\ormlite.h:438: 无构造函数可以接受源类型,或构造函数重载决策不明确 orm-lite\ormlite.h:231: 参见“BOT_ORM_Impl::SerializationHelper::Serialize”的声明 orm-lite\ormlite.h:435: 在编译 类 模板 成员函数“BOT_ORM::Expression::SetExpr BOT_ORM::Expression::NullableField::operator =(T)”时 with [ T=int ] orm-lite\sample.cpp:327: 查看对正在编译的函数 模板 实例化“BOT_ORM::Expression::SetExpr BOT_ORM::Expression::NullableField::operator =(T)”的引用 with [ T=int ] orm-lite\sample.cpp:280: 查看对正在编译的 类 模板 实例化“BOT_ORM::Expression::NullableField”的引用

请问有遇到过类似的问题吗

不知道作者使用的是什么编译环境,我也出现了完全一样的问题,需要修改序列化部分的code才可以编译成功 ormlite.h line: 240 static inline bool Serialize(std::ostream& os, const std::string& value) => template static inline bool Serialize(std::ostream& os, const T& value)

line: 276 static inline void Deserialize(std::string& property, const char* value) => template static inline void Deserialize(T& property, const char* value)

Deserialize函数内的 property = value 的赋值操作需要根据模板T的类型自行判断 // exp std::is_same<T, int>::value ... std::is_same<T, double>::value ... std::is_same<T, std::string>::value ...

s8642795130 avatar Nov 01 '21 07:11 s8642795130