Cereal macro for vector

128 Views Asked by At

ALL.

In the cereal there is a macro CEREAL_NVP, that is suitable for the map/pair.

Is there some kind of macro suitable for std::vector?

I have:

private:
    std::vector <MyObjectId> RecordVector;
    template <class Archive>
    void serialize( Archive &ar )
    {
        ar( CEREAL_NVP( RecordVector ) );
    }

and I still got the error:

/home/ikorot/work/TPW/External/cereal/include/cereal/cereal.hpp:954:9: error: static assertion failed: cereal could not find any input serialization functions for the provided type and archive combination. 

 Types must either have a serialize function, load/save pair, or load_minimal/save_minimal pair (you may not mix these). 
 Serialize functions generally have the following signature: 

 template<class Archive> 
   void serialize(Archive & ar) 
   { 
     ar( member1, member2, member3 ); 
   } 

 
         static_assert(traits::detail::count_input_serializers<T, ArchiveType>::value != 0,
         ^

And I did include cereal/types/vector.hpp.

TIA!

1

There are 1 best solutions below

0
On

You need to make the serialize function public or use the cereal::access friend class to make it accessible to cereal.