On Sun, Oct 12, 2008 at 5:37 PM, Benoît Jacob
<jacob@xxxxxxxxxxxxxxx> wrote:
> I've seen it done as a template parameter in at least one other
> framework. Since they're templates, and hence being inlined, a compiler
> should optimize out the if block in the case of a constant being used.
> I feel like having them rolled into one function would make the API
> easier to work with (less functions to scan), but of course the final
> decision is with you guys.
Indeed, a single template function lpNorm<p>() might be the way to go.
Just FYI, yes the compiler will ultimately emit code for only one path, but it
will still go over all paths at least in the front-end, making compilation
longer. This can be avoided by "meta-selectors" i.e. using template
specialization instead of if().
ok, I agree with that proposal. and here we can directly use template specialization of lpNorm<>, no need to use a meta selector.
gael