[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compilation failure, template problems
From: |
Michael Goffioul |
Subject: |
Re: Compilation failure, template problems |
Date: |
Sat, 14 Nov 2009 17:13:56 +0000 |
I think I narrowed down the problem to the following
piece of code, which does not compile under MSVC.
If I remove the 'g' overloads to only keep the 'double'
one, then it compiles fine.
Any chance to get a workaround?
Michael.
#include <iostream>
template <class T>
class A
{
public:
typedef T element_type;
};
template <class T, typename T::element_type fun(typename T::element_type)>
void f()
{
std::cout << "f<T>" << std::endl;
}
double g(double x) { std::cout << "g(double)" << std::endl; return x; }
int g(int x) { std::cout << "g(int)" << std::endl; }
float g(float x) { std::cout << "g(float)" << std::endl; }
int main(int argc, char **argv)
{
f<A<double>,g>();
return 0;
}
On Sat, Nov 14, 2009 at 3: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.
>