Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-09-08 10:58:37


OK - I think I understand you now.

a) we don't know all the derived classes so we can't use "register"
b) BOOST_CLASS_EXPORT doesn't work with templates.
c) An attempt to use the underlying defintion of BOOST_CLASS_EXPORT fails
because each class needs its own distinct name and we don't have a portable
way of automatically generating something like:

"my_class<int>" from class<T> when T == int

So we have to make a new export invocation by hand for each template
instantiation. This gets us back to square one in that we don't know
apriori all the types that will be used as template parameters.

I don't have a general solution for this.

In the longer term it might be solvable in general. This problem has been
discussed in some detail from time to time. In the shorter term you could
probably craft a solution that would not be a general solution but might
work in some cases. If you don't care about archive portability - that is
if your only loading archives with the same compiler (and probably standard
library), you could craft something which would generate a uniquename from
type_id.

Robert Ramey

Bruno Martínez wrote:
> On Thu, 08 Sep 2005 04:37:03 -0300, Robert Ramey <ramey_at_[hidden]>
> wrote:
>
>> Hmm - I the referenced email referred to shared_ptr.
>
> The link's mail's subjects was
> Serialize templates classes > automatique exportdeclaration
> . I didn't get the part about it referring to shared_ptr.
>
>> Your case is covered
>> in the documenation. Reference/Serializable/Pointers.
>
> The problem is that I never know a priori the instantiations of the B
> template class present in a program, so I can't register them all.
> My use case is a boost::function like class, where type erasure is a
> must. It's very difficult to register a bind result type. Do you
> understand me now?
>
> Thank you,
> Bruno


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