I would like to do something like the following:
class Foo
{
Foo(int &&a, int b, std::string s="");
// does not compile because a is not an rvalue:
// Foo(int &&a, std::string s) : Foo(a, 0, s) {}
Foo(int &&a, std::string s) : Foo(std::move(a), 0, s) {} // move a
}
- Is this a valid way to overload a constructor in general?
- And specifically one that takes an rvalue reference as a parameter?
Edited based on comments
To clarify, I'm new to move semantics (and an amateur programmer) and I'm simply not sure if this is a good way to handle this situation.
I added the first question based on a comment (now deleted) that suggested this is not the correct way to overload constructors.