you are viewing a single comment's thread
view the rest of the comments
[–] [S] 1 point 2 years ago (2 children)

I wonder if the language could be updated so these extra std::move invocations actually become harmless? return std::move is something that I see used quite a bit.

These std::move invocations are harmless, as they only cast objects to their rvalue reference.

The destructive bit takes place in the type they are assigned to, as it invokes either a move constructor or a move assignment operator, and calling those implies that the object you just passed to std::move will be invalidated after the call and should not be used subsequently.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 2 years ago (1 child)

    @lysdexic @QuadriLiteral Eh, no. Really. Changing the value category disables RVO

  • source
  • parent
  • hideshow 2 child comments
  • [–] [S] 1 point 2 years ago (1 child)

    RVO

    I recommend you read the thread.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 years ago (1 child)
  • [–] [S] 1 point 2 years ago (1 child)

    It doesn't look like it, otherwise you'd be aware that the whole point of this submission is that casting return values with std::move disables RVO.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 years ago (1 child)

    @lysdexic You claimed otherwise:
    "
    These std::move invocations are harmless, as they only cast objects to their rvalue reference.
    "
    If you were right, we wouldn't have the motivation to look at this in EWG.

  • source
  • parent
  • hideshow 2 child comments
  • [–] [S] 1 point 2 years ago

    If you were right, we wouldn’t have the motivation to look at this in EWG.

    I am right. Not benefiting from RVO does not mean you're harming anyone.

    Again, I recommend you read the submission and also the discussion.

  • source
  • parent