模板错误的投射对象

问题描述

我有以下问题。有一个功能

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;
}

如果我传输字符串编译器给我下一个问题: screen

error C2039: at: not member "std::basic_istream" typetostring.h(语言不通)

如果我从值变量“Valuetochararray(Type value)”中删除链接,我会得到下一个错误

错误 C2280:“std::basic_ostream::basic_ostream(const std::basic_ostream &)”:你无法获得链接删除功能

我需要在字符串类型命中函数时处理它。 VS 说我这种类型是 std::ostream 但这个函数链接...

注意!可以使用 c++11 或 c++14。函数被重载。不建议更改 fx 调用。您不能为字符串类型创建单独的函数。我将感谢所有至少会提供一点帮助的人。对不起语言:D

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)