C++ template instantiation with complex type -



C++ template instantiation with complex type -

i want instantiate function template argument similar next complextype.

template <class u, class type> struct complextype; template <class type> struct complextype<double, type> { typedef type t; }; template <class type> struct complextype<int, type> { typedef type t; };

i got next in header file

template <typename u> void xyz( typename complextype<u, double>::t abc);

and implementation in cpp file

template <typename u> void xyz( typename complextype<u, double>::t abc) { abc = 1.0; } template void xyz( complextype<double, double>::t abc);

unfortunately gcc giving me next compiler error message

template-id xyz<> void xyz(complextype<double, double>::t) not match template declaration

any suggestions of how resolve this?

u isn't deduced argument. need explicit template specification:

template void xyz<double>( complextype<double, double>::t abc);

you can do:

template void xyz<double>(double);

c++ templates

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -