English 中文(简体)
如何序列化推进 :: uuds:: uud
原标题:how to serialize boost::uuids::uuid

目前我使用推力: uuds: uuds: uuds: unids in a Project : uudd: uuds: uuds:: uud。 我尝试了下面的简单例子,但我有一个错误:

/ usr/ including/ bust/ gistrive/ basic_ text_ oprimitive. hpp: 92: 错误: 没有匹配 ` operator<<'在'(( (( 强制 : : : : : 授权 : 基础_ text_ ominimitive & gt; *) 中 ) & gt; 启动: 授权: 基础: 基础: _ text_ otrimitive & gt; : os< < t” 中 的 匹配 。

如果有人能帮我,我会非常喜欢的

#include <fstream>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_serialize.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>

class classA {
public:
    classA() : id(boost::uuids::random_generator()()) {}
private:
    friend class boost::serialization::access;
    boost::uuids::uuid id;
    template <class Archive>
    void serialize(Archive& ar, const unsigned int version) {
        ar & id;
    }
};

int main(void) {
    classA a;
    std::ofstream ofs("uuid.txt");
    boost::archive::text_oarchive oa(ofs);
    oa << a;
    ofs.close();
    return 0;
}
问题回答

Include <boost/uuid/uuid_serialize.hpp> to enable serialization for uuids. http://www.boost.org/doc/libs/1_42_0/libs/uuid/uuid.html#boost/uuid/uuid_serialize.hpp





相关问题
Choosing the right subclass to instantiate programmatically

Ok, the context is some serialization / deserialization code that will parse a byte stream into an object representation that s easier to work with (and vice-versa). Here s a simplified example ...

WCF Problem Sending Object To Client

Background Converting from using .Net Remoting to WCF. Most of the methods on the WCF server are working fine, but ran into one that isn t working today. This is the service contract: [...

WCF DataMember Serializing questions

Ok, so I was part way through the long winded process of creating DTOs for sending my model over the wire and I don t feel like I m going down the right route. My issue is that most of the entities ...

deserialize the XML Document --- Need Help

I am using the below code snippet now to deserialize the XML document ... [WebMethod] public XmlDocument OrderDocument(XmlDocument xmlDoc) { XmlSerializer serializer = new XmlSerializer(typeof(...

How do I serialize a child class?

how do I include the serialized data from a child class where both impliment iserializeable? Class A Implements ISerializable dim _B as new B Class B Implements ISerializable ...

WCF: Serialize complex objects with read-only members

Looking for some guidance on a WCF service I’m prototyping. I have a WCF service hosted in IIS that will pass data to my clients. I have a separate shared assembly that contains all my business ...

Long/multiple SQL queries vs Serialization

I m trying to improve the performance of my web app where a page does a long query to pull data from different tables on a database. It pulls invoice data with multiple item lines, invoice status, and ...

热门标签