C ++ std :: ctype< char> :: widen()的作用是什么? [英] C++ What is the role of std::ctype<char>::widen()?
问题描述
根据C ++标准(C ++ 17草案(N4659)的第30.7.5.2.4条), out<<如果
ch
是 char
并且 out
是 std :: ostream
.
According to the C++ standard (§30.7.5.2.4 of C++17 draft (N4659)), out << ch
will not perform a widening operation on ch
, if ch
is a char
and out
is a std::ostream
.
这是否意味着保证 std :: ctype< char> :: widen()
(即 char
-> char
)按标准是对基本源字符集中的所有字符的标识函数( widen(ch)== ch
)?
Does this imply that std::ctype<char>::widen()
(i.e., char
-> char
) is guaranteed by the standard to be an identity function (widen(ch) == ch
) for all characters in the basic source character set?
如果是这样,这是否意味着标准要求所有语言环境都使用来自基本源字符集的字符的相同非宽度(或多字节)编码?
If so, does this, in turn, imply that all locales are required by the standard to use the same non-wide (or multi-byte) encoding of characters from the basic source character set?
如果不是,则好像是 out<<'x'
,对于文字有特殊的字符编码选择,即使在某些语言环境中也可能无法在所有语言环境中使用.也就是说,可能没有选择字符文字编码的方式,例如 out<<'x'
同时在所有语言环境中起作用.
If not, it seems like out << 'x'
, with a particular choice of character encoding for literals, might not work in all locales, even when it works in some. That is, there might be no choice of character literal encoding, such that out << 'x'
works in all locales simultaneously.
推荐答案
不,它只是说
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, char c);
其中流和<<
运算符都使用相同的 char
类型进行交易,则不进行转换.
where both the stream and the <<
operator trades in the same char
type there is no conversion.
如果
c
的类型为char
,并且流的字符类型不是char
,则seq包含out.widen(c)
;否则seq由c
组成.
If
c
has typechar
and the character type of the stream is notchar
, then seq consists ofout.widen(c)
; otherwise seq consists ofc
.
在所有其他情况下,可以使用语言环境来选择性地转换字符,而对语言环境的作用没有任何限制.
In all other cases the locale is used to optionally transform the character with no restrictions on what the locales might do.
这篇关于C ++ std :: ctype< char> :: widen()的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!