Boost logo

Geometry :

Subject: Re: [geometry] dimension type of geometries
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2013-07-26 09:23:13


Hi,

2013/7/25 Bruno Lalande <bruno.lalande_at_[hidden]>

>
> Can you point us to the places where some compilers complain? It might
> just be that there's a better way to do the static comparison. I'm asking
> that because it seems to me that since we'll only touch some of the
> involved traits, the problem will still remain for the other libraries
> anyway.
>
>
Probably nowhere in the library. I'm thinking about the situation when
someone wants to write his own algorithm using a structure template and to
check if passed index is ok, he uses static_asert. Something like this:

template <class Geometry, size_t I>
struct my_algo
{
    BOOST_STATIC_ASSERT(I < dimension<G>::value);
    /*...*/
    my_algo<Geometry, I+1>::
    /*...*/
};

Ok, you may check dimensions outside, in some function calling the
algorithm implementation. Then pass size_t Dimension, as it is done in the
BG. Still, you could check if your implementation is ok, e.g. you didn't
passed Geometry incompatible with passed Dimension, "in-place" where the
algorithm is implemented.

This just shows small inconsistency in the definition of dimension.

We could also strictly define its type as signed and use signed ints in
algorithms.

Regards,
Adam



Geometry list run by mateusz at loskot.net