Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-11-24 01:53:47


Robert Ramey wrote:

>>class BlockFormula : public std::map<int, int> {
>>public:
>> int i;
>> template<class Archive>
>> void serialize(Archive& ar, unsigned)
>> {
>>ar & i;
>> }
>>};
>
> what happens when "unsigned" is changed to "const unsigned int" does
> this fix the problem?

No, I get the same error message. And no wonder: *this* serialization is not
causing ambiguity, the ambiguity is between global 'serialization'
functions.

Can I ask why the trick with third argument is needed at all? The comment
says it's workaround for lack of 'Partial Template Specialization'. Hmm...
are you sure you're not workarounding lack of partial template ordering on
some compilers.

E.g. if I have the following set

template<class A, class T>
void serialize(A&, T&, unsigned) { /* forward to class method */ }

template<class A, class K, class V>
void serialize(A&, std::map<K, V>&, unsigned) { /* do something smart */ }

struct B : public std::map<int, int> {}

template<class A>
void serialize(A&, B&, unsigned) { /* do something even more smart */ }

Then partial template ordering should select first version only if no other
version can work.

>>I can't find serialization for std::pair in the latest draft. Is it
>>possible to include the attached in the new version?
>
> try boost/serialization/utility.hpp
>
> I chose this because std::pair is found in <utility>
> BTW boost/serialization/utility.hpp includes <utility> same
> thing for vector, list, etc.

Okay, that's fine with me.

>>Another, unrelated comment. If void_cast can't find direction
>>transformation it tries intermediate types with:
>
>> for ( it = global_registry().m_set.begin();
>> it != global_registry().m_set.end();
>> ++it )
>
>>I.e. it considers *all* knows types. Is this behaviour really desired?
>>Can't be just consider all transformation for the current from_type?
>
> the set is keyed on the from-to pair. you can't get just the members
> corresponding to half the key. Remember that this operation
> is only done once. when a matching pair is found, its added to the
> set so it doesn't have to be done again - so execution time is not
> a consideration.

Hmm... hopefully I'll run serializaton under profiler one day and will
inform you what I find then.

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk