template<typename T>
class MultidimArray:
{
public:
T* data;
long int xinit;
...
private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive &ar, const unsigned int version){
ar & data;
ar & xinit;
ar & ...;
}
};
stringstream ss;
void serializateWs(){
MultidimArray<DOUBLE> Mpack;
boost::archive::text_oarchive oa(ss);
oa << Mpack;
}
Compile error: request for member ‘serialize’ in ‘t’, which is of non-class type ‘double’. But it will be fine without "T * data". I found an answer How to serialize derived template classes with Boost.serialize? I add this line "oa.template register_type< MultidimArray >();". But I got this " error| ‘template’ (as a disambiguator) is only allowed within templates" when compiling. How can I serialize and deserialize this kind of class?