一元 + 可接收指针,实现类型的转换:

    1. #include <cstdio>
    2. int main()
    3. {
    4. int a[3] = {1,2,3};
    5. const auto& x = +a;
    6. const auto& y = a;
    7. }

    Insight:

    1. #include <cstdio>
    2. int main()
    3. {
    4. int a[3] = {1, 2, 3};
    5. int *const & x = +a;
    6. int const (&y)[3] = a;
    7. }

    加减法可以接收指针:

    1. #include <iostream>
    2. int main()
    3. {
    4. int a[3] = {1,2,3};
    5. std::cout << std::cend(a) - std::cbegin(a) << std::endl;
    6. } //输出3,即为数组a的长度

    一元 + 会发生integral promotion:
    (减法也会,但一般会改变正负)

    1. #include <iostream>
    2. int main()
    3. {
    4. short a = 6;
    5. auto b = + a;
    6. }

    Insight:

    1. #include <iostream>
    2. int main()
    3. {
    4. short a = 6;
    5. int b = +static_cast<int>(a);
    6. }

    整数相除会产生整数,向 0 取整

    求余只能接收整数类型操作数,结果符号与第一个操作数相同

    满足 (m / n) * n + m % n == m