Boost logo

Boost Users :

Subject: Re: [Boost-users] can not compile nearest neighbors in d dimensions
From: Lars Viklund (zao_at_[hidden])
Date: 2014-04-16 06:37:04


On Wed, Apr 16, 2014 at 12:02:39PM +0200, Georgios Samaras 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?

It's not really about Boost. It's about understanding the fundamentals
of templates. They are instantiated at compile-time, and instantiations
with distinct parameters are distinct types.

If you want to make a runtime choice based on a runtime count, you need
to either have instantiations of the template for each and use a wrapper
that applies sufficient type erasure/hiding, or you would have to have a
type that has runtime-parametricism in dimensions.

If your question is: "does this library have a type with
runtime-configurable dimensionality" and "can I use that type with the
algorithms", you should probably ask _that_ question instead.

-- 
Lars Viklund | zao_at_[hidden]

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