字符串连接与字符串字面量和非字符串字面量。

huangapple go评论59阅读模式
英文:

String concatenation with string literal and non string literal

问题

constexpr auto type = u"bluetooth-opp-transfer-complete"_ns;

这个声明中,constexpr 表示在编译时评估。u 表示这是一个 Unicode 字符串。_ns 应该是一个用户自定义的后缀或名称,它可能在其他地方定义,用于标识字符串的某种特殊含义或命名空间。

英文:

I want to understand what the following declaration means:

constexpr auto type = u"bluetooth-opp-transfer-complete"_ns;

I know constexpr evaluates things at compile time, but what does u mean here? Also will _ns gets appended here? if yes then how cause _ns is not defined anywhere.

答案1

得分: 1

"u"使它成为UTF-16字符串字面量。更多选项请参见cppreference,例如。

英文:

The u makes it a UTF-16 string literal. For more options see cppreference, for example.

huangapple
  • 本文由 发表于 2023年6月12日 18:23:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76455703.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定