|
Boost Users : |
Subject: Re: [Boost-users] can not compile nearest neighbors in d dimensions
From: Mateusz Åoskot (mateusz_at_[hidden])
Date: 2014-04-16 05:34:57
On 16 April 2014 11:28, Georgios Samaras <georgesamarasdit_at_[hidden]> wrote:
>>The compiler is right, as in this context of template instantiation,
>>M must denote a constant expression
>>and M must not be evaluated at run-time.
>
> The compiler is "always" right. How Boost.Geometry allows me to achieve my
> purpose (i.e. creating a M-dimension point)?
> I tried to work around it, but
> I failed and can not find any workable solutions in Google. Moreover, I
> didn't find anything about that in the docs.
First, you need to understand requirements on non-type template
parameters in C++
(dimension is an integer, not a type), that it must be a constant expression
known at compile-time, *not* run-time!
Second, look at docs for geometry model, namely point
The example presents how to instantiate point template to generate
types for 2D and 3D points:
bg::model::point<double, 2, bg::cs::cartesian> point1;
bg::model::point<double, 3, bg::cs::cartesian> point2
where 2 and 3 denote your M value.
Long story short:
int const M = 3;
typedef bg::model::point<float, M, bg::cs::cartesian> point;
Best regards,
-- Mateusz Åoskot, http://mateusz.loskot.net
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