Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-01-29 11:42:59


On Sat, 27 Jan 2001, David Abrahams wrote:
abraha>
abraha> BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_integer ||
abraha> RandomAccessIteratorConcept<T>::value);
abraha>
abraha> But I don't think I can do that... can I?

It is not possible for the concept checking library to produce the
"::value". This is because it either causes a compiler error or not... and
it is not possible to catch a compiler error and convert to a value.
This is a problem in general with "structural" conformance checking in
C++.

However, it is possible to look at the iterator category and produce
a value. In fact, we already have a mechanism for this.

is_convertible< typename std::iterator_traits<T>::category,
                std::random_access_iterator_tag>::value

Some people have reffered to this as "named" conformance.

However, in your example I don't see why the concept check can not be
written on a separate line, using the usual mechanism.

abraha> The other thing I love about BOOST_STATIC_ASSERT() is that
abraha> don't need to remember to write checks differently based
abraha> on context, wheras the concept checking lib has
abraha> boost_function_requires<>() and BOOST_CLASS_REQUIRES().

I'll take a look at the implementation of BOOST_STATIC_ASSERT(). Perhaps I
can borrow a trick to make it work for concept checking.

abraha> Also [aside], I realize that the concept checking classes
abraha> share most of their names with the concepts themselves,
abraha> but does that really justify using MixedCaseNames in this
abraha> case? After all, we have names like forward_iterator_tag
abraha> as precedent in the standard, and standard precedent is
abraha> why we chose this naming convention.

I think it does justify using mixed case.

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