6 Matching Annotations
  1. Apr 2022
    1. std::move_if_noexcept will return a movable r-value if the object has a noexcept move constructor, otherwise it will return a copyable l-value. We can use the noexcept specifier in conjunction with std::move_if_noexcept to use move semantics only when a strong exception guarantee exists (and use copy semantics otherwise).

      如果在 move 过程中遇到异常,有什么办法可以处理?

    1. std::move can be used whenever we want to treat an l-value like an r-value for the purpose of invoking move semantics instead of copy semantics.

      std::move 在什么情况下可以使用?

    1. First, r-value references extend the lifespan of the object they are initialized with to the lifespan of the r-value reference (l-value references to const objects can do this too). Second, non-const r-value references allow you to modify the r-value!

      R-value references 有什么性质非常有用?

  2. Jan 2022
  3. Dec 2021
  4. Apr 2021