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
Post a Comment