Original Post
I have these two string conversion functions:
The first simply returns its parameter, since they are the same type and no conversion is necessary. The second performs a conversion using wcstombs, mbstowcs, or some other method.
This line of code
Produces this error
I'm wondering how to achieve the effect of automatically calling the correct Covert method using templates. That is to say, the compiler should know when the types are the same and call the first method.
template <typename T> const T * UTIL::Convert(const T *, const size_t, size_t &);template <typename T, typename U> const T * UTIL::Convert(const U *, const size_t, size_t &);The first simply returns its parameter, since they are the same type and no conversion is necessary. The second performs a conversion using wcstombs, mbstowcs, or some other method.
This line of code
const UTIL::Char * ptrText = UTIL::Convert<UTIL::Char>(p_ptrText, p_intLength, uintLength);Produces this error
1>c:\development\assware\common\src\gui\factory.cpp(220) : error C2668: 'UTIL::Convert' : ambiguous call to overloaded function1> c:\development\util\include\util\impl\traits.h(47): could be 'const T *UTIL::Convert<UTIL::Char,XML_Char>(const U *,const size_t,size_t &)'1> with1> [1> T=UTIL::Char,1> U=XML_Char1> ]1> c:\development\util\include\util\impl\traits.h(14): or 'const T *UTIL::Convert<UTIL::Char>(const T *,const size_t,size_t &)'1> with1> [1> T=UTIL::Char1> ]1> while trying to match the argument list '(const XML_Char *, int, size_t)'I'm wondering how to achieve the effect of automatically calling the correct Covert method using templates. That is to say, the compiler should know when the types are the same and call the first method.