Hello

First all, sorry for my long post, and I hope I will be clear with the question.

In my project I have a lot of classes, which I plan to serialize with boost serialization library.

Most of my classes have as members third party library classes. The thing is that the third party library classes are very complex and I can't serialize them directly  in the standard way i.e I can't say this  :

   template<class Arhive,class MyThirdPartyClass>
   void serialize(Archive& ar, MyThirdPartyClass& t, const unsigned int version)
   {
      ar & t.meber1;
      ar & t.member2;
      ....
}

MyThirdparty library classes all provide their own method for serialization ( storing in custom archive and reading from the archive), so I was thinking to do this :

namespace boost
{
    namespace serialization
   {
         template<class Archive>
         inline void save(Archive & ar, const CustomClass& t, const unsigned int version)
          {
                 /// save t to the custom archive here .    
          }

         template<class Archive>
         inline void load(Archive & ar, CustomClass& t, const unsigned int version)
          {
                ////// read data from archive and assign to t
          }
   }
}

Now when I do the following :

// save data
CustomClass* cc=new CustomClass(.....);
outarchive & cc;

/// later on read
CustomClass * rcc=0;
inarchive & rcc;

delete rcc;   ///  (*)     crash here. delete is operator implemented in my CustomClass

I notice that the crash maybe has to do something with that, that  my CustomClass implements its own new and delete operators.

I know that the default implementation of load_construct data uses operator placement ::new ( global new operator ) to allocate object when loading through pointer,  and I am deleting the object above ( * ) with its specific class delete operator. To avoid the mismatch I did this :

template<class Archive>
        inline void load_construct_data(Archive & ar,  CustomClass * t, const unsigned int file_version)
        {         
            new (t) CustomClass; // notice that this is the custom class operator  , not :: new
        }

In my suprise (*) is still crashing. Why ?

Also I notice that if in load_construct data I am using the global new operator, and when deleting the global ::delete ( i.e :: delete rcc) operator there is no problem at all. But this is not solution, cause I want my CustomClass to use their own specific operators new and delete.