我有这个代码:
class USerializer {
public:
template<typename T>
static std::string serialize(std::list<T*> listOfObjectToSerialize)
{
// stringstream containing serialized Objects
std::stringstream serializedObjectList;
typename std::list<T*>::iterator iter;
// serialize Objects
for (iter = listOfObjectToSerialize.begin(); iter != listOfObjectToSerialize.end(); ++iter)
{
// Class delimiter
serializedObjectList << '+'<< endl;
// Need to serialise the class itself, and not the pointer to it!
serializedObjectList << **iter;
}
return serializedObjectList.str();
}
}
然后我使用这样的方法:
std::string serializedAlarmInfo = USerializer::serialize<CcAlarm::AlarmInfo>(getActiveAlarms());
我收到一个 SIGILL 错误:
Program received signal SIGILL, Illegal instruction.
使用 gdb 我跟踪了执行情况,在我退出序列化函数之前一切似乎都很好。
有任何想法吗?