[英]Why is the return type of std::reverse_iterator::operator[] unspecified?
I was wondering, why, in C++, the return type of std::reverse_iterator::operator[]
is left unspecified. 我想知道,为什么,在C ++中, std::reverse_iterator::operator[]
的返回类型未指定。 Shouldn't it be std::reverse_iterator::reference
? 不应该是std::reverse_iterator::reference
吗?
This is actually a superfluous relaxation; 这实际上是一种多余的放松; As of LWG 448 and LWG 299 (over N3066 ), which are incorporated in C++11, iterators' return types of operator[]
shall be convertible to reference
. 从LWG 448和LWG 299 ( N3066 )开始,它们包含在C ++ 11中,迭代器的operator[]
返回类型应该可以转换为reference
。 The original LWG issue that introduced this underspecification ( 386 ) was unfortunately resolved before the one that changed the requirements on the return type of operator[]
. 不幸的是,在改变了对operator[]
的返回类型的要求的问题之前解决了引入这种不足规范( 386 )的原始LWG问题。
Since the return type of iterators' operator[]
is now mandated to be convertible to reference
, the return type of reverse_iterator::operator[]
can clearly be just reference
- and it is, in both libc++ and libstdc++. 由于迭代器的operator[]
的返回类型现在被强制转换为reference
,因此reverse_iterator::operator[]
的返回类型显然只是reference
- 它在libc ++和libstdc ++中都是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.