Date: Tue, 21 Oct 2025 14:42:57 +0100
On Tuesday, October 21, 2025, SD SH wrote:
> Then how will you implement it?
>
> Think of this:
> ```
> SYSCLASS struct Accessor; // unmovable and uncopyable
>
> extern SYSAPI Accessor (*access)();
>
> int main() {
> StoreAndGet<Accessor>(access());
> }
> ```
> We don't know what the function will do, and it's impossible to change the
> function. We only know that access() will construct a Accessor object and
> follow the calling convention, then we must call copy or move constructor,
> but in this case we can't do it.
>
> For your example, if a function returns a unmovable and uncopyable object
> means that you shouldn't construct it by existing objects in your code.
>
That function pointer, i.e.'access', points to a function that returns an
Accessor by value. On x86_64 Linux, this means that when the function
pointer is invoked, the RDI register will contain the address where the new
object is to be constructed. We have all the info we need.
> Then how will you implement it?
>
> Think of this:
> ```
> SYSCLASS struct Accessor; // unmovable and uncopyable
>
> extern SYSAPI Accessor (*access)();
>
> int main() {
> StoreAndGet<Accessor>(access());
> }
> ```
> We don't know what the function will do, and it's impossible to change the
> function. We only know that access() will construct a Accessor object and
> follow the calling convention, then we must call copy or move constructor,
> but in this case we can't do it.
>
> For your example, if a function returns a unmovable and uncopyable object
> means that you shouldn't construct it by existing objects in your code.
>
That function pointer, i.e.'access', points to a function that returns an
Accessor by value. On x86_64 Linux, this means that when the function
pointer is invoked, the RDI register will contain the address where the new
object is to be constructed. We have all the info we need.
Received on 2025-10-21 13:42:59
