小编Mae*_*anz的帖子

如果未在c ++之前定义,则定义函数/方法

我还没有使用C++ 11,所以我to_string(whatever)自己编写了这些函数.只有在它们不存在时才应编译它们.如果我切换到C++ 11,应该跳过它们.我有这样的事情:

#ifndef to_string

string to_string(int a){
    string ret;
    stringstream b;
    b << a;
    b >> ret;
    return ret;
}

string to_string(double a){
    string ret;
    stringstream b;
    b << a;
    b >> ret;
    return ret;
}

#endif
Run Code Online (Sandbox Code Playgroud)

这显然不起作用.这样的事情是可能的,如果是的话,怎么样?

c++ methods function precompile c++11

14
推荐指数
2
解决办法
2376
查看次数

标签 统计

c++ ×1

c++11 ×1

function ×1

methods ×1

precompile ×1