V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
V2EX  ›  ruoshan  ›  全部回复第 1 页 / 共 1 页
回复总数  1
2019 年 7 月 4 日
回复了 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`. 他们两个编译出来的代码是一样的.
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3301 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 13:29 · PVG 21:29 · LAX 06:29 · JFK 09:29
♥ Do have faith in what you're doing.