Suppose there is a function like this:
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)
{
}
Is there a way to warn programmers to avoid such mistakes with std::move
? This is not about unique_ptr
only but for other objects too.
Is there any mechanism to generate a warning when we used a moved-from object inappropriately?