C++ 叮当声错误,没有可行的转换
我面临一个关于Clang3.1的问题。GCC 4.2中不存在这一特殊问题。以下是发生错误的示例:C++ 叮当声错误,没有可行的转换,c++,gcc,clang,wchar-t,char16-t,C++,Gcc,Clang,Wchar T,Char16 T,我面临一个关于Clang3.1的问题。GCC 4.2中不存在这一特殊问题。以下是发生错误的示例: #include <stdio.h> #include <iostream> #include <sstream> #include <string> typedef unsigned short char16_t; typedef char16_t TCHAR; typedef std::basic_string<TCHAR, std::c
#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
};
#包括
#包括
#包括
#包括
typedef无符号短字符16_t;
类型def char16_t TCHAR;
typedef std::basic_字符串wstringT;
模板
内联wstringT MyTestFunction(常量T和源代码)
{
std::wstringstream out;
out如果你想使用TCHAR
你必须使每个模板都展开以使用它,包括wstringstream
你实际上想要一个基本的\u stringstream
或者你可以:
typedef std::basic_stringstream<TCHAR> tstringstream;
typedef std::basic_stringstream tstringstream;
为什么不使用wchar\u t
作为TCHAR
?wchar\u t
可能与无符号短字符
akachar16\u t
相同,也可能不同。
typedef std::basic_stringstream<TCHAR> tstringstream;