J'ai du laisser ce problème de coté quelques temps, mais me revoilà
j'ai fait comme vous avez dit et j'ai réussi à sauver en text et en binaire
le problème se situe maintenant au niveau du chargement
donc pour rappel l'enregistrement donne
1 2 3 4 5 6 7 8 9 10 11
| Use *u = new Use();
std::ofstream ofs(filename, ios::binary);
// save data to archive
boost::archive::binary_oarchive oa(ofs);
oa.register_type<GenericBase<float> >();
oa<<u; |
et le chargement :
1 2 3 4 5 6 7 8 9
| Use *u;
std::ifstream ifs(filename, ios::binary);
// save data to archive
boost::archive::binary_iarchive ia(ifs);
ia>>u; |
compilation sans problème par contre à l'exécution, erreur :
1 2 3 4 5
| Assertion failed: new_cid == cid, file libs\serialization\src\basic_iarchive.cpp,
line 450
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information. |
maintenant avec Use u et non plus Use* u :
1 2 3 4 5 6
|
terminate called after throwing an instance of 'boost::archive::archive_exception'
what(): stream error
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information. |
si dans la classe Use je mets en commentaire , le problème persiste, mais si en plus de ça je mets en commentaire
oa.register_type<GenericBase<float> >();
alors plus d'erreur (mais uniquement pour Use* u);
j'ai essayé d'ajouter
ia.register_type<GenericBase<float> >();
au chargement avec en retour ceci à la compilation :
error: no matching function for call to 'GenericBase<float>::GenericBase()'
en fait
oa.register_type<GenericBase<float> >();
me permet de réaliser la sauvegarde mais fait obstacle au chargement
Partager