Boost logo

Boost :

Subject: Re: [boost] [contract] concepts: pseudo-signatures vs. usage patterns
From: Andrew Sutton (asutton.list_at_[hidden])
Date: 2012-10-11 20:55:52


> For examples of forced conversions inserted to deal with this issue,
> search for "pred" in
> http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/include/bits/stl_algo.h?view=markup

Interesting. It's terrifying that somebody should have to do that.

> Looking at N3351, I wonder if you implemented these algorithms and threw
> strict archetypes at the implementations. It looks very much like you
> would need similar contortions.

We did (omitting a handful), with constraints mostly matching what
appeared in n3551, but the archetype framework wasn't in place until
some time later.

If I remember correctly, we assumed that a conversion requirement on
the result of an operation, would actually convert (if necessary). You
couldn't, for example, return tribool from == and expect the compiler
to pick up overloads for &&, ||, and !. That would be a bad thing
(unless your generic algorithm was parameterized over the underlying
logic).

I'm not sure if you can successfully guard against this using
SFINAE-constraints. You'd need to write a ton of explicit conversions
(like above). Or language support, of course.


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