Boost logo

Boost Users :

Subject: Re: [Boost-users] can not compile nearest neighbors in d dimensions
From: Mateusz Łoskot (mateusz_at_[hidden])
Date: 2014-04-16 06:34:03

On 16 April 2014 12:30, Mateusz Łoskot <mateusz_at_[hidden]> wrote:
> On 16 April 2014 12:02, Georgios Samaras <georgesamarasdit_at_[hidden]> wrote:
>>>Long story short:
>>>int const M = 3;
>> I have checked the link already. Yes, I had tried that it worked, but, as I
>> said the dimensions are going to be read from a file given by the user (that
>> is run time I guess). That means that Boost can not let the user apply a
>> desired dimension?
> You need to use multiple models and dispatch between them in runtime.

You may find this overview helpful

"BG uses a generic programming paradigm, just as the entire Boost
library does. BG is mostly composed of function templates and class
templates, so it’s not OK to use the dynamic polymorphism paradigm
here, we instead have to statically dispatch geometry objects of each
type to the right version of each BG spatial function call."

IOW, you need to think of these two as separate types:

bg::model::point<double, 2, bg::cs::cartesian> point1;
bg::model::point<double, 3, bg::cs::cartesian> point2;

like one is std::vector<float> and one is std::vector<int>.

Best regards,

Mateusz  Łoskot,

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at