On Sat, Nov 14, 2009 at 8:52 PM, Jaroslav Hajek <
address@hidden> wrote:
>
>
> On Sat, Nov 14, 2009 at 4:31 PM, Michael Goffioul
> <
address@hidden> wrote:
>>
>> Hi,
>>
>> Using recent octave archive, MSVC fails to compile liboctave due
>> to a template problems. The error is the following:
>>
>> ../../liboctave/CNDArray.cc(763) : error C2563: mismatch in formal
>> parameter list
>> ../../liboctave/CNDArray.cc(763) : error C2563: mismatch in formal
>> parameter list
>> ../../liboctave/CNDArray.cc(763) : error C2440: 'specialization' :
>> cannot convert from 'overloaded-function' to 'double (__cdecl *const
>> )(Complex)'
>> None of the functions with this name in scope match the target type
>> ../../liboctave/CNDArray.cc(763) : error C2973: 'do_mx_unary_map' :
>> invalid template argument 'overloaded-function'
>>
>> c:\sources\playground\c\octave-graphics-hg\liboctave\mx-inlines.cc(264)
>> : see declaration of 'do_mx_unary_map'
>> ../../liboctave/CNDArray.cc(763) : error C2668: 'do_mx_unary_map' :
>> ambiguous call to overloaded function
>>
>> c:\sources\playground\c\octave-graphics-hg\liboctave\mx-inlines.cc(271):
>> could be 'RNDA do_mx_unary_map<NDArray,ComplexNDArray,double
>> std::abs<double>(const std::complex<double> &)>(const XNDA &)'
>> with
>> [
>> RNDA=NDArray,
>> XNDA=ComplexNDArray
>> ]
>>
>> c:\sources\playground\c\octave-graphics-hg\liboctave\mx-inlines.cc(264):
>> or 'RNDA do_mx_unary_map<NDArray,ComplexNDArray,& abs>(const
>> XNDA &)'
>> with
>> [
>> RNDA=NDArray,
>> XNDA=ComplexNDArray
>> ]
>> while trying to match the argument list '(const ComplexNDArray)'
>>
>> Any idea how to work around the problem? This part of the code seems
>> pretty recent.
>>
>> Michael.
>
> I think this should compile - name resolution for template function
> parameters works like for regular parameters. Here the signature is fully
> determined by the previous parameters, so a unique match should be found.
> So I think this is a bug in MSVC.
> Unfortunately, the typical way to pick a specific overload (cast the name
> reference to specific function pointer type) doesn't work in this case,
> because only integral and enum casts are allowed in template params. Maybe
> just specifying std::abs<double> instead of std::abs would work? Otherwise,
> I think you'll need to wrap std::abs in a function with unique name and
> substitute that for the template parameter.