标准预定义了哪些用户定义的文字? [英] Which user-defined-literals are predefined by the standard?
问题描述
我的问题听起来像是一个矛盾,但是除了 user-defined-literal
.我不知道该如何引用新的文字语法.
My question sounds like a contradiction, but I don't know how else to refer to the new literal syntax other than user-defined-literal
.
std::string operator "" s ( const char* str, size_t len )
{
return std::string( str, len );
}
assert( "foo"s == "bar"s );
我记得听到用户定义的文字应该以 _
前缀开头.这意味着该库为我们定义了一些非前缀的文字.
I remember hearing that user defined literals should start with an _
prefix. That would imply that the library defines some non-prefixed literals for us.
标准是否在标准库中提供一些UDL?
如果是,那是什么?
Does the standard provide some UDLs in the the standard library?
If yes, what are they?
推荐答案
该语言已使用常规文字后缀,例如 1U
.
The language already use regular literals suffixes, for example 1U
.
如果您将 U
用作用户定义的文字,那么建议将变得模棱两可.
It would become ambiguous if you were to use U
as a user-defined-literal, thus the recommendation.
整数后缀: u
, U
, l
, L
, ll
, LL
浮动后缀: f
, F
, l
, L
这篇关于标准预定义了哪些用户定义的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!