dimanche 14 mars 2021

boost serialization vector in c++

Hello so i have this two classes and i want to serialize the vector

class PlayerInventory
{
private:
    friend class boost::serialization::access;
    template <class Archive>
    void serialize(Archive &ar, const unsigned int version)
    {
        ar &itemID &itemCount;
    }

public:
    int itemID;
    int itemCount;
};

class player
{
private:
    friend class boost::serialization::access;
    template <class Archive>
    void serialize(Archive &ar, const unsigned int version)
    {
        ar &username &password &inv;
    }

public:
    string username;
    string password;
    std::vector<PlayerInventory> inv;
};

for some reason its not serializing the full vector just first 2 elements is this the correct way of doing it ?

Aucun commentaire:

Enregistrer un commentaire