I am playing with the fluent interface pattern.
First, I wrote something like that:
class C
{
public:
C() { }
C* inParam1(int arg1){ param1 = arg1; return this; }
C* inParam2(int arg2){ param2 = arg2; return this; }
private:
int param1;
int param2;
}
Then I tried to use the std::unique_ptr, but then I realized that I do not know how to "shift" the pointer (this) along the chain. I tried something like:
return std::move(this);
that of course does not work.
How can I do this? Are there any problems doing something like this?
In order to reply to comments like: "do not use pointers": there isn't (yet) any practical reason because I am doing this with pointers, is just something I wonder if can be done this way.