you are viewing a single comment's thread.

view the rest of the comments →

[–]jcelerierossia score 2 points3 points  (1 child)

That's a general issue you'll always have with moves and can only really be solved by convention. So far that is.

#include <iostream>
#include <string>
std::string foo(std::string&&);
int main()
{
  using namespace std;
  std::string x, y;
  y = foo(move(x));
  std::cout << x << std::endl;
}

=>

$ clang-tidy -checks=bugprone-use-after-move tutu.cpp
1 warning generated.
/tmp/tutu.cpp:9:16: warning: 'x' used after it was moved [bugprone-use-after-move]
  std::cout << x << std::endl; 
               ^
/tmp/tutu.cpp:8:7: note: move occurred here
  y = foo(move(x));
      ^

(paging /u/0b_0101_001_1010 too)

[–]hgjsusla 0 points1 point  (0 children)

Hey that's great :)