Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] Non-default constructor and template class
From: Rüdiger Berlich (ruediger.berlich_at_[hidden])
Date: 2015-06-15 15:46:25


Hi Kurt,

you should be able to simply define a private default constructor, if boost::serialization::acess is declared as a friend of your class. There is no need to initialize variables that are in your serialize() function, as Boost.Serialization should set their values after default construction. So in most cases the default constructor may be empty and is trivial to implement, while it can not be called by any external entity (except if it is also declared „friend“).

Kind Regards,
Beet

> Am 15.06.2015 um 21:38 schrieb Mccall, Kurt E. (JSC-EG411) <kurt.e.mccall_at_[hidden]>:
>
> I am attempting to serialize a template class without a default constructor, so I am overriding boost::serialization::save_construct_data().
> I'm not sure of the correct syntax to declare that function. The line marked below fails to compile with a "too many template-parameter-lists"
> error.
>
> // Forward declaration of my class
> template<class Key, class Value, class Hasher>
> class HashMap;
>
> namespace boost { namespace serialization {
>
> template<class Archive>
> template<class Key, class Value, class Hasher>
> void save_construct_data(Archive &ar, const HashMap< Key, Value, Hasher > *t, const unsigned int file_version); // error here
> }}
>
>
> Thanks for any help,
> Kurt
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net