Note: To clarify, the question is not about the use of the restrict
keyword in general, but specifically about applying it to member functions
The link you posted is interesting. There will not be a solid use case for having restrict
applied on this
. As you mentioned in your question, copy constructor, operator = could have been potential candidates; but compiler can take care of them.
But following case can be interesting
struct A
{
//...
void Destroy (A*& p) __restrict__
{
delete this;
p = 0;
p++;
}
};
Now use case can be;
A **pp = new A*[10];
for(int i = 0; i < 10; i++)
pp[i] = new A;
//...
A* p = pp[0];
for(int i = 0; i < 10; i++)
p->Destroy(p);
delete[] pp;
Though this is very unusual practice, this is the only case I could think of this use case.