相关疑难解决方法(0)

是否为C++标准允许的自定义类型的std :: to_string专门化?

在C++ 11及更高版本中,是否允许专用std::to_stringstd自定义类型的命名空间?

namespace std {
string to_string(::MyClass const & c) { return c.toString(); }
}
Run Code Online (Sandbox Code Playgroud)

示例用例:

int main() {
    MyClass c;
    std::cout << std::to_string(c) << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

c++ std tostring specialization c++11

36
推荐指数
4
解决办法
4630
查看次数

标签 统计

c++ ×1

c++11 ×1

specialization ×1

std ×1

tostring ×1