C++ Logo


Advanced search

Re: [std-proposals] this return type

From: Jan Schultke <janschultke_at_[hidden]>
Date: Sun, 9 Apr 2023 11:18:48 +0200
> Shouldn't compilers optimise this similarly to cache the vtable pointer?

> https://godbolt.org/z/zxj7nxr9s

No, the implementation cannot cache the vtable pointer because the
vtable pointer can change between member function calls. This happens
if the member function explicitly ends and begins the lifetime of this
inside of the function.

Received on 2023-04-09 09:19:00