Some clarification on rvalue references

前端 未结 3 462
暗喜
暗喜 2021-02-08 10:35

First: where are std::move and std::forward defined? I know what they do, but I can\'t find proof that any standard header is required to include them

3条回答
  •  庸人自扰
    2021-02-08 11:10

    where are std::move and std::forward defined?

    std::move and std::forward are declared in . See the synopsis at the beginning of section 20.3[utility].

    When implementing move semantics, the source is presumably left in an undefined state.

    It of course depends on how you implement the move-constructor and move-assignment operator. If you want to use your objects in standard containers, however, you have to follow the MoveConstructible and MoveAssignable concepts, which says that the object remains valid, but is left in unspecified state, i.e. you definitely can destroy it.

提交回复
热议问题