On Sun, Nov 15, 2009 at 10:11 PM, Michael Goffioul
<address@hidden> wrote:
On Sun, Nov 15, 2009 at 8:21 PM, Jaroslav Hajek <
address@hidden> wrote:
> Wicked. Why is it picking the wrong version? There are both `fun (T)' and
> `fun (const T&)' versions defined...
My feeling is that MSVC is not able to handle the function as
template parameter, when it's using inner types in the signature.
When doing some testing, I could even get stupid error messages
like: cannot cast 'double(__cdecl *)(double)' to 'double(__cdecl *
const)(double)
> What about this?
> If not, I'm out of ideas...
I'll give it a try, but I'm not very optimistic about the outcome.
What does work is to move "fun" out of the template parameters
and provide it as a function argument.
The reason why the function is a template argument is to unify the signature of all unary loops: (size_t, R *, const T*).
This makes it possible to define separately "loops" (which do some data transformations using pointers) and "appliers" which apply these functions to Array objects. I'd like to try to keep the loops and appliers as orthogonal as possible.
Besides, having a function as a template parameter means that the compiler will almost surely inline the call as direct, improving performance.
When I get octave fully
compiled, I'll send a patch and leave up to you to decide whether
you want use/refactor it. I can live with my own patch.
Michael.