V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  ruoshan  ›  全部回复第 1 页 / 共 1 页
回复总数  1
2019-07-04 18:45:49 +08:00
回复了 fetich 创建的主题 C++ 请教《C++ Primer》一书中有关显式类型转换的问题
string 的构造函数有一个是这个:
`basic_string( const CharT* s, const Allocator& alloc = Allocator() );`

static_cast<std::string>(cp) 和 std::string(cp) 是一样的效果.

你可以编译一下 `g++ -std=c++11 -g -S x.cc` 看一下 `x.s`. 他们两个编译出来的代码是一样的.
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4967 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 08:20 · PVG 16:20 · LAX 01:20 · JFK 04:20
Developed with CodeLauncher
♥ Do have faith in what you're doing.