template wählt falsche Funktion
-
Ich habe foldenden Code
vector<double> amplitudeTime; maxpos = ArrayCenterPos(amplitudeTime, 250.0);mit foldendem Code in Header Datei
template<typename T> int ArrayCenterPos(vector<T> const & InArray, T threshold) { return ArrayCenterPos(&InArray[0], (int)InArray.size(), threshold); } template<typename T> int ArrayCenterPos(T * InArray, int size, T threshold) { ... } int ArrayCenterPos(complex<double>* InArray, int size, double threshold) { ... }ich bekomme aber den Fehler:
1>h:\Dev\CPP\SVN\modelocksimulation\ModelockingSimulation2\include\matthias\Common\ExtFunctions.h(325) : error C2664: 'int ArrayCenterPos(std::complex<double> *,int,double)' : cannot convert parameter 1 from 'const double *__w64 ' to 'std::complex<double> *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1> .\src\LaserData.cpp(130) : see reference to function template instantiation 'int ArrayCenterPos<double>(const std::vector<_Ty> &,T)' being compiled
1> with
1> [
1> _Ty=double,
1> T=double
1> ]den ich nicht vetstehe.
-
pospiech schrieb:
... den ich nicht vetstehe.
1>h:\Dev\CPP\SVN\modelocksimulation\ModelockingSimulation2\include\matthias\Common\ExtFunctions.h(325) : error C2664: 'int ArrayCenterPos(std::complex<double> *,int,double)' : cannot convert parameter 1 from 'const double *__w64 ' to 'std::complex<double> *'
Ich denke du solltest in der Fehlermeldung ein besonderes Augenmerk auf das const legen, dann wird es vielleicht klarer.

-
das Fehler mit const war mir noch nicht aufgefallen, aber der Grund für diese Fehlermeldung war schlicht eine fehlende Funktionsdeklaration...
-
pospiech schrieb:
Grund für diese Fehlermeldung war schlicht eine fehlende Funktionsdeklaration...
Glaube ich zwar nicht, aber sei's drum ...
