“复制”实现示例中的运算符优先级
Operator precedence in `copy` implementation example
我读了几行代码,在我看来应该有一些括号。
template<class InputIterator, class OutputIterator>
OutputIterator copy ( InputIterator first, InputIterator last, OutputIterator result )
{
while (first!=last)
*result++ = *first++; // <--- this line
return result;
}
根据这里的操作符优先级表,我认为后缀自增操作应该优先,然后是解引用操作,然后是赋值操作。但在我看来,它的意图是先解引用,然后赋值,然后是后缀自增。
我读错了吗?还是表错了,还是代码段错了?还是另有隐情?
先执行后置自增操作,但是后置自增操作的返回值是指针的原始值。
相关文章:
- C++ 带有函数指针的运算符优先级
- <<运算符优先级与字符串比较
- 在一个指令中声明更多指针的运算符优先级
- C++中的运算符优先级
- c++中的增量和三元运算符优先级
- 涉及模运算符优先级的错误以及C++中具有大数字的括号
- 带有 cout 和指针的运算符优先级
- C++ 使用矢量迭代器时的运算符优先级
- 序列点和运算符优先级有什么区别
- 运算符优先级 括号问题
- C++表达式中的运算符优先级
- 相等运算符优先级不起作用
- 递增和按位移位运算符优先级?
- 运算符优先级超载在C 中
- C++ 中的递增/递减和输出流运算符优先级
- 输出流中的运算符优先级C++
- 运算符优先级C++
- C++11 何时相对于运算符优先级进行算术类型转换
- 从表中了解运算符优先级
- 是否违反 C/C++ 运算符优先级和关联性规则?