So how such thing can be used to create such silly nesting functions: Z.reset(...C.reset(B.reset(A.get()))...) so a function would loock like
char * reset(char * buffer)
{
...
return buffer;
}
so… my question is – such thing is acceptable in C++ simple API you would show to people or not?
Technically, this is allowed. Strictly, it is acceptable. But I still wouldn’t do it.
The only reason I can think of to engineer a function like this is to support Method Chaining, which I think is an abomination. Opinions on this differ. You may love them, think they are nice & expressive, good for IntelliSense, what have you. Indeed, sometimes it might even be the Right Thing.
Method Chaining aside, I don’t see what this gets you that you’d want. In fact, I think it gets you something you don’t want: confused semantics. If someone is looking at your header file they are going to see this return and wonder why they need it. They may think it is something it’s not, like memory they have to manage or something. Who knows. But the semantics are not entirely clear. So I would avoid it.