I have a function that gets a "Config" struct, which at the moment is simply a struct that contains an array
class ShmConfig {
public:
std::int64_t shellShmSize[ShellId_Count];
};
And I pass it on to another function in the function with std::move
, because I want all code places that copy it be agnostic to the fact that it can efficiently be copied.
m_allocator.setup(std::move(config));
If later it can be more efficient to move it (maybe because I add an std::string
to it), it will automatically be become more efficient. But clang-tidy
advises against it
std::move
of the variable 'config
' of the trivially-copyable type 'ShmConfig
' has no effect; removestd::move()
I don't understand why this is desirable. Is there any disadvantage to wrapping it with move
? Are these advices to be followed only if one runs clang-tidy regularly, so that one can spot cases of where std::move
will make sense later on, upon data member additions?