When is the move constructor called in the `std::move()` function?

后端 未结 2 1326
余生分开走
余生分开走 2021-01-04 06:16

The function std::move() is defined as

template
typename std::remove_reference::type&& move(T && t)
         


        
相关标签:
2条回答
  • 2021-01-04 06:41

    std::move is just a type cast, it tells the compiler that the type is an rvalue.

    0 讨论(0)
  • 2021-01-04 06:44

    There is no move construction going on. std::move() accepts a reference and returns a reference. std::move() is basically just a cast.

    Your guess 4. is the right one (assuming that you are actually calling a move constructor in the end).

    0 讨论(0)
提交回复
热议问题