Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-09-06 12:54:47


"Robert Ramey" <ramey_at_[hidden]> writes:

>>> Note that his concept is different than others in the standard
>>> library in that one of the requirements is that it be a class with
>>> certain required member functions.
>>>
>>> Most or all other concept definitions only specify
>>> operations for which the type is valid. As far as I know this doesn't
>>> include supporting specific member functions.
>
>> Actually, no. All of the concepts in the Container hierarchy share
>> that property.
>
> Of course. And I did study the SGI documentation in that regard. Now that
> I think about, I'm sure this is where I got the idea to do it this way.

Then why not use the generally accepted and understood format for
describing concepts?

>> Well, CRTP might be a good option for you, especially considering that
>> function implementation I mentioned in the first paragraph above.
>
> As I said, Ive used CRTP in the implementation. But I could imagine someone
> making an archive class that didn't use CRTP and still have the archive
> function. So I see it as an implementation detail rather than part of the
> concept.

If it is not somehow part of the concept requirements that the archive
have boost::serialization as an associated namespace, their
boost::serialization::serialize() won't be considered as a candidate
overload on a conforming compiler.

>> So the question is, does the user actually need to use default
>> arguments where your interface description does, or would overloads
>> work just as well? Since you don't have a description of how to
>> interpret your prototype, the answer is unclear.
>
> The only default argument is
>
> register_type(T * t = NULL);
>
> and its only there because many compilers don't accept the syntax:
>
> ar.template register_type<T>()
>
> Its optional to support compilers that do support the above syntax. So I
> guess that should be explained.

It should be explained carefully. Does the serialization library call
register_type differently on those other compilers?

IMO you'd be better off simply leaving out "template" on those
compilers, if you can get away with it.

      ar.register_type<T>()

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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