struct that
{
that &frob()
{
return *this;
}
that frob() const
{
return that(*this);
}
//that &&frob() && //<-called only if *this is an rvalue
//{
// return move(*this);
//}
that()
{
// make things
}
that(const that &other)
{
// copy things
}
that(that &&other)
{
// move things
}
};
Obviously the function in comments above is not legal C++, but I need to know if there is a way to accomplish this:
that().frob().frob().frob();
and so on, while each call to frob()
would effectively call the "move" version thereof. As this is something that can be determined at compile time, I can't think of any reason for it to not exist in some form.
I can write something like this:
that &&frob(that &&t)
{
return t;
}
Which would result in this:
frob(frob(frob(that())));
Which is somewhat annoying to read and doesn't accomplish my goal of "spelling things out" with delegation.