[PATCH] D21223: [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument

Martin Böhme via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 14 06:21:45 PDT 2016


mboehme added inline comments.

================
Comment at: test/clang-tidy/misc-move-const-arg.cpp:75-76
@@ +74,4 @@
+
+struct NonMoveable {
+ public:
+  NonMoveable();
----------------
aaron.ballman wrote:
> This type isn't non-moveable. For that, you need to explicitly delete the move constructor. Perhaps a better name is `NonMoveConstructible`?
> 
> Also, no need for the `public` access specifier.
> This type isn't non-moveable. For that, you need to explicitly delete the move constructor.

Can you expand on this?

The standard says: "If the definition of a class X does not explicitly declare a move constructor, one will be implicitly declared as defaulted if and only if - X does not have a user-declared copy constructor [...]" (12.8/9).

Because I'm declaring a copy constructor, I would thus have expected not to get an implicitly-declared move constructor. Where am I going wrong here?

> Perhaps a better name is NonMoveConstructible?

But the type _is_ move-constructible (in the sense of std::is_move_constructible<>).

> Also, no need for the public access specifier.

Oops -- thanks for catching this.

Actually, I meant to make this a class -- not sure how the "struct" slipped in there.

================
Comment at: test/clang-tidy/misc-move-const-arg.cpp:116
@@ +115,3 @@
+struct Moveable {
+ public:
+  Moveable();
----------------
aaron.ballman wrote:
> No need for the `public` access specifier.
Thanks for cathching this -- as above, I meant to make this a class.


http://reviews.llvm.org/D21223





More information about the cfe-commits mailing list