Boost logo

Boost :

Subject: Re: [boost] [1.44] Beta progress?
From: Matthias Troyer (troyer_at_[hidden])
Date: 2010-07-23 16:47:47


On 22 Jul 2010, at 18:42, Robert Ramey wrote:

> Matthias Troyer wrote:
>> On 22 Jul 2010, at 13:39, Robert Ramey wrote:
>>>>
>>>> I totally disagree with your statements that we depend on internal
>>>> details of Boost.Serialization. Boost.Serialization does publish an
>>>> (incomplete!) archive concept and you did intend that others can
>>>> extend it with new archive classes.
>>>
>>> The published archive concept specifes the concepts that must
>>> be fullfilled by any serializable types. The serialization
>>> library includes examples of archives which depend upon only
>>> on the documented concepts.
>>>
>>> The documentated archive concepts don't prevent other archive
>>> classes from including more functionality. Indeed, facilities such
>>> as serialization of pointers through a base class, etc demand it.
>>> And it's true that I haven't discouraged leveraging on these
>>> "extended archives"
>>
>> I'm talking about the requirements on a minimal archive. Those are
>> not fully documented.
>
> Hmmm that would be news to me. I compiled trivial archive from
> the documentation with serialization code. And trivial archive
> is model of minimal archive. That is I believe that serializing
> any types to a trivial archive will compile without error.
> If there is a serializable type which trivial archive fails
> to work with, I would be interested in hearing about it.

You misunderstand. The concepts should specify:

1) what primitive types the archive needs to be able to serialize
2) what concepts these primitive types satisfy that can be used.

Do you want to say that the trivial archive should be used to deduce that?

class trivial_oarchive {
public:
    //////////////////////////////////////////////////////////
    // public interface used by programs that use the
    // serialization library
    typedef boost::mpl::bool_<true> is_saving;
    typedef boost::mpl::bool_<false> is_loading;
    template<class T> register_type(){}
    template<class T> trivial_oarchive & operator<<(const T & t){
        return *this;
    }
    template<class T> trivial_oarchive & operator&(const T & t){
        return *this << t;
    }
    void save_binary(void *address, std::size_t count){};
};

This class satisfies the following:

1) it can deal with ANY type
2) it uses NO property of the types

Clearly, those are not the requirements for all archives. If we next look at the text archives we'll find that

1) it can deal with any primitive type that can be streamed to in i/ostream
2) it uses the streaming operator of those types

Are those the requirements? Again not. What we need is an explicit list of all primitive types that an archive is required to support, and a list of the properties of those types that a user can rely on. For example, all the primnitive types had a default constructor and I used it but now you say that was an implementation detail that I should not have used. How can I as an archive implementor know what I may use without risking breakages?

Matthias


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