3 Comments
User's avatar
Sukraat Ahluwalia's avatar

There does exist a clang-tidy check for this, performance-move-const-arg: https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/performance-move-const-arg.html

It also checks for when the argument is trivially copyable, where a std::move() would be a no-op.

Expand full comment
Taras Tsugrii's avatar

yes, it does, but it's a separate tool that at best runs as part of CI or lint checks, which is why sometimes it's useful to rely only on built-in compiler facilities like static_assert.

Expand full comment
Sukraat Ahluwalia's avatar

That is true. While some IDE's, Emacs have plugins with clang-tidy integration, nothing drives the point like a static_assert().

Expand full comment