C++11 新添加的变量定义后缀支持

Standard user-defined literals[edit]
C++11 defined the syntax for user-defined literal suffixes, but the standard library did not use any of them. C++14 adds the following standard literals:[16]
“s”, for creating the various std::basic_string types.
“h”, “min”, “s”, “ms”, “us”, “ns”, for creating the corresponding std::chrono::duration time intervals.
“if”, “i”, “il”, for creating the corresponding std::complex, std::complex and std::complex imaginary numbers.

auto str = "hello world"s; // auto deduces string
auto dur = 60s;            // auto deduces chrono::seconds
auto z   = 1i;             // auto deduces complex<double>

The two “s” literals do not interact, as the string one only operates on string literals, and the one for seconds operates only on numbers.[18]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值