Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost Concept Library - fusion and other libraries
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2011-03-20 19:23:49


Robert Ramey wrote:

> [Noticing that the Boost Concept Check library (BCCL) is not used as
> much as one might expect from the documentation, however starting to
> appreciate the value of concepts, and wondering whether there is
> really a discrepancy between the value of concepts and the extent of
> the adoption of the BCCL.]

If this isn't a good abstract of your email, please say so.

Assuming it's good enough: I wondered about this too. I'll share my
personal conclusions with you and hope it helps.

For a start, I think the most important purpose of concepts is
documentation. You define your concept once, at least in natural
language and optionally also through the BCCL formalisms, and after
that you can use just a single word again and again to refer to an
entire set of operations that should be supported, as well as their
semantics. If you adopt this view, it's not so strange for a library
to use concepts in the documentation (verbally) but not in the code
(as compile-time checks).

A secondary value of concepts is that they can make compiler errors
more readable. Because the BCCL was developed (almost?) entirely for
this purpose, from its documentation it may seem a bit like improving
compiler errors is the primary purpose of concepts in general.

I think the use of the BCCL (contrary to the use of concepts for
documentation) can also have disadvantages, i.e. in terms of
maintainability and readability of the code. Hence, when concept
requirements are fairly straightforward, the templates in question are
so short that the code would almost double if you add a
BOOST_CONCEPT_REQUIRES, or the compiler errors aren't too hard to
understand after all, this may be enough reason for a library
developer to not use the BCCL even though they do use concepts in the
documentation.

Note, that most (if not all) Boost libraries that don't use the BCCL
still use concepts in the names of template arguments or in comments
as a form of within-code documentation. For example, I'm quite sure
I've seen this in the Boost.Random and the Boost.MinMax header files.

Also note that concepts were voted out of the C++0x standard proposal
about a year ago (IIRC). This might be partly due to the same reasons
that many Boost libraries don't use compile-time concept checks.

HTH, Julian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net