Boost logo

Boost :

From: Bruno Lalande (bruno.lalande_at_[hidden])
Date: 2008-05-09 16:11:40

Hi Luke,

> You do raise a valid point, there is currently no concept checking
> included in the design and implementation I checked into the sandbox.
> Is it valid to call something a concept if there is no concept checking?

Yes it is. But in my opinion, showing up a concept class has the
advantage of clearly communicating the intention to the community in
order to validate / invalidate the design. Moreover, since two
geometry-related libraries are currently being developed for Boost
(even if they don't do the same things) I think comparing the concepts
used would allow us to see exactly what are the convergences /
divergences, and see what can or cannot be done to make them as close
as possible. A certain level of consistency between those libraries
would surely be appreciated.

Barend and me have written the following point concept (it's obviously
open to criticism):

template <class X>
struct Point
    typedef typename point_traits<X>::coordinate_type ctype;
    enum { ccount = point_traits<X>::coordinate_count };

    template <class P, int I, int Count>
    struct dimension_checker
        static void check()
            const P* point;
            ctype coord = point_traits<X>::template get<I>(*point);
            P* point2;
            point_traits<X>::template get<I>(*point2) = coord;

            dimension_checker<P, I+1, Count>::check();

    template <class P, int Count>
    struct dimension_checker<P, Count, Count>
        static void check() {}

        dimension_checker<X, 0, ccount>::check();

It actually forwards everything to the point_traits class in order to
check that everything needed is accessible through point traits for
the point type begin checked. Since you rely on point traits too, I
suppose you would have the same approach?

If you don't want to do that right now because you're afraid about the
profusion of concept checking macros in your code, I think that
putting a BOOST_CONCEPT_ASSERT in the point_traits class is sufficient
with this approach, since any access to a point should be performed
only through this class. This way, you don't have to rewrite the check
in every algorithm, and the only job you have to do is writing the
concept class. However, as I'm not used yet with the BCCL, I can be


Boost list run by bdawes at, gregod at, cpdaniel at, john at