Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2000-11-25 11:52:32


On Fri, 24 Nov 2000, Beman Dawes wrote:
> >class class_requires_test
> >{
> > typedef class_requires< EqualityComparableConcept<int> >::check req1;
>
> That's not so good. The "typedef", "::check", and "req1" detract from the
> clarity of the code. I worry developers will shy away from using concept
> checks because of the ugly code.
>
> Another worry: in testing an early compile time asserts proposal which used
> a similar typedef technique, I found a number of slight coding mistakes
> would compile OK, but not actually do the indicated check. What happens if
> a user codes any of these mistakes (where X is a UDT that isn't Equality
> Comparable)?

I performed these tests using g++:

> class_requires< EqualityComparableConcept<X> >::check req1;
This compiles, but I can rig things to make it fail.

> class_requires< EqualityComparableConcept<X> >::check;
This compiles :( Wierd, I didn't think this would compile.

> class_requires< EqualityComparableConcept<X> > req2;
This compiles, but I can rig it to fail.

> class_requires< EqualityComparableConcept<X> >;
This compiles :(

> typedef class_requires< EqualityComparableConcept<X> > req3;
> typedef class_requires< EqualityComparableConcept<X> >;
Both of these also compile :(

> If they fail to compiler, fine, but if they compile without error, and fail
> to detect the error, I would be concerned. If they did error check OK, but
> generated code because the typedef was missing, that would also be a
> concern. Could you give them a try?
>
> While the macros were, well, macros, they were also very clear, and seemed
> hard to misuse IMO.

There is also some hidden nastyness in the macros. For example, the type
arguments to the macros cannot contain commas or spaces, or other
non-identifier characters.

However, on the whole, I think you are right. I'll keep the
BOOST_CLASS_REQUIRES macros.

Cheers,

Jeremy

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


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