Yes, using the move has no disadvantage in that situation. All copyable objects are automatically moveable, so it doesn't matter. In fact, some recommend to always move variables when possible, even integers.
As an alternative, you may consider to use perfect forwarding, as described in this answer:
template <typename T2>
foo(T2&& t) : m_t(std::forward<T2>(t)) {}
If you know that T
defines a fast move constructor, it should not matter. Otherwise, providing a constructor foo(const T&)
is recommended to avoid unnecessary copies.
Perfect forwarding is only one technique to achieve that. The solution of Pubby to write out the constructor foo(const T&)
and foo(T&&)
is, of course, also fine. The results are the same, it is mostly a matter of style.
You also asked about small integer types. In theory, passing them by reference is slower than copying them, but the compiler should be able to optimize it to a copy, anyway. I don't think it will make a difference.
So, better optimize for the worst case where T
can be huge and does not provide a fast move constructor. Passing by reference is best for that situation and should not be a bad choice in general, either.