c++11 - 模板错误的演员表对象
问题描述
我有以下问题。有一个功能:
int main()
{
//...
std::string test = "1234";
std::string result = ValueToCharArray(test);
//...
}
template<class Type>
std::string ValueToCharArray(Type& value)
{
std::string buffer = "";
//...
if (typeid(std::string) == typeid(value))
{
std::cout << typeid(std::string).name() << '\n' << typeid(value).name() << '\n';
value.at(0);
//...
}
short int i = 0;
while (i<3)
{
buffer += '?';
i++;
}
buffer[i] = 0;
return buffer;
}
如果我传输字符串编译器给我下一个问题: 屏幕
错误 C2039: at: not member "std::basic_istream<char,std::char_traits>" typetostring.h(对不起语言)
如果我从值变量“ValueToCharArray(类型值)”中删除链接,我会收到下一个错误:
错误 C2280:“std::basic_ostream<char,std::char_traits>::basic_ostream(const std::basic_ostream<char,std::char_traits> &)”:您无法在已删除函数中获取链接
当字符串类型命中函数时,我需要处理它。VS说我这种类型是std :: ostream但是这个函数链接......
注意!可以使用 c++11 或 c++14。函数重载。不建议更改 fx 调用。您不能为字符串类型创建单独的函数。我将感谢所有至少提供一点帮助的人。对不起语言:D
解决方案
推荐阅读
- bash - 如何列出具有小字符文件名的文件?
- azure - Set-AzSqlServerActiveDirectoryAdministrator:找不到 Azure Active Directory 对象“service_principal_name”
- swift - AVAudioPlayer 不认为它在播放时
- c# - 拦截并阻止特定窗口的 ALT 按键
- telegram - 在 MQL 中添加 Telegram InlineKeyboardButton
- firebase - Flutter:在firebase中编写文档的问题
- c++ - 如何在 C++ 中递归合并队列?假设它们已经排序
- ios - 共享文本 iPhone 和 iPad
- jestjs - isVueInstance 已弃用,将在未来版本中删除
- reactjs - 反应表不显示数据