Boost logo

Boost Users :

From: Olivier Vanden Bos (olivier.vanden-bos_at_[hidden])
Date: 2005-05-10 12:38:13


I think there have been a lot of discussion about this,

It might been related to the template serialization traits in the
documentation , but the explanation was a little to subtle for me, \

 

In fact, I cannot really understand how to avoid

The unregistered exception when I use a template like this.

 

 

// template declaration pseudo code

 

Class A

{

            Virtual ~A(){};

            template<class Archive> void serialize(Archive & ar, const
unsigned int version){};

};

 

Template <T> Class B : public A

{

T Object;

 

            B(T& _object)

{

Object=_object;

}

            

            template<class Archive> void serialize(Archive & ar, const
unsigned int version)

{

            Ar & Object;

};

}

 

 

//Main Code

 

Vector<A*> array;

 

Template<T> void Add(T& val)

{

      B<T>* objectToAdd= new B<T>(val)

array.push_back(objectToAdd);

}

 

//User code

 

Add((int)0);

 

 

 

And when i archive the array in another .cpp the exception is raised,
because

the class B<int> as not been exported.

 

I would like to avoid explicitly declare

BOOST_CLASS_EXPORT_GUID(B<int>, "B_int")

For each instanciation of B<> somewhere in the global space.

In the Add() or in the template declaration that s ok, but I cannot
suppose what types that the user will use.

 

Thanks in advance..

 

- VDB -
 "LNK2019: unresolved external symbol"
                   
 Olivier Vanden Bos MSN#TheVdeub_at_[hidden]
 AI Programmer
 UBISOFT Montreal

 

 

 

 



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