gau*_*waj 7 move-semantics c++11 c++14
假设有这样的函数:
int * func()
{
  std::unique_ptr<int> ptr(new int(3));
  //Few more lines of code
  //then one function added where programmer writes like some thing
  SOME_OTHER_FUNC(std::move(ptr));
  return ptr.get();
}
void SOME_OTHER_FUNC(std::unique_ptr<int> arg_ptr)
{
}
有没有办法警告程序员避免这样的错误std::move?这unique_ptr不仅仅是针对其他对象而已.
当我们不恰当地使用移动对象时,是否有任何机制来生成警告?
Seb*_*edl 15
std::move 是警告.如果您的程序员不理解这一点,您必须更好地教育他们.如果函数太长以至于程序员可以合理地忽略移动,那么你需要重构你的函数以缩短它.