Boost logo

Boost :

Subject: Re: [boost] [serialization] Proposal: make 'version' trait (andothers)enable_if-friendly
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-12-06 16:30:25


On Thu, Dec 6, 2012 at 1:22 PM, Robert Ramey <ramey_at_[hidden]> wrote:

> Gabriel Redner wrote:
> > Hi Robert,
> >
> > Thanks for taking a look, and for developing the library!
> >
> >> Hmm - doesn't the fillowing work? - for each T used
> >>
> >> template <>
> >> struct version<Foo<t>::MyType>{
> >> BOOST_STATIC_CONSTANT(unsigned int, value = 1);
> >> };
> >>
> >> I understand it might be a little more tedious and not that clever
> >> but it's much, much, much less time consuming to understand,
> >> documment, explain
> >> and support. Your suggestion is clever - but I just don't think it's
> >> cost effective.
> >
> > Technically - yes, I could probably enumerate all types. However, my
> > example is severely simplified and in reality the 'Foo'-equivalent has
> > several template parameters. Enumerating all of the combinations
> > would create its own maintenance nightmare and essentially defeat the
> > benefits of templating.
> >
> > I don't mean to dismiss your suggestion, but I think you are looking
> > at things from the wrong perspective. Your objection seems not to be
> > with the proposed library change, but with how I am going to use it.
>
> It's not so much that, its with the work I have to do to implement it,
>

I.e., patches welcome.

> address compiler dependent issues,

None AFAIK (this technique is already used in Boost).

> document it,

Optional for the moment, I'd say.

> explain it to people
> who ask about it (it's not obvious), etc.
>

Easy way is to refer them to Boost.Proto docs et al. (I forget the rest of
the libraries that do this).

>> From the library's point of view, this is a change that increases
> > flexibility while leaving existing use-cases untouched. Since this
> > pattern is common in other boost libraries, I would say there is a
> > clear need for it as well as precedent. If a user doesn't need the
> > added flexibility, they can ignore the extra parameter. But, if a
> > user *does* need it, it's a lifesaver.
>
> There's nothing that prevents you from implementing your own change.
>
> Actually I'm still trying to wrap my head around why
>
> template<Foo<T>::MyType > doesn't work.
>

T is not in a deduced context, i.e., the compiler cannot deduce what T is.
You can try it yourself if you don't believe me :)

- Jeff


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