Clang error, no viable conversion
c++, char16-t, clang, gcc, wchar-t
Solution
If you want to use `TCHAR` you have to make every template expand to use it including `wstringstream` you actually want a `basic_stringstream<TCHAR>` or you could:
typedef std::basic_stringstream<TCHAR> tstringstream;
Problem
I am facing an issue with clang 3.1. This particular issue does not arise with GCC 4.2. The following is an example of the error that occurs: ``` #include <stdio.h> #include <iostream> #include <sstream> #include <string> typedef unsigned short char16_t; typedef char16_t TCHAR; typedef std::basic_string<TCHAR, std::char_traits<TCHAR>, std::allocator<TCHAR> > wstringT; template<class T> inline wstringT MyTestFunction(const T& source) { std::wstringstream out; out << source ; return out.str(); // error occurs here }; ``` The error message states: ``` No viable conversion from '__string_type' (aka 'basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >') to 'wstringT' (aka 'basic_string<TCHAR, std::char_traits<TCHAR>, std::allocator<TCHAR> >') ``` The code is compiled with the compiler flag -fshort-wchar, which is supposed to convert wchar_t to a 16 bit unsigned short. I am compiling the code on XCode v4.3.2.