Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

See https://news.ycombinator.com/item?id=39812834 for a more complete explanation.


If I follow that link and end up here:

https://www.digitalmars.com/articles/b68.html

I find:

> C++ and D diverge here. D has the notion of a delegate, aka “fat pointer”, which is a pair consisting of a pointer to the member function and a pointer to the ‘this’ object. The virtualness of the member function was resolved at the point where the address of the member function was taken

> Alternatively, C++ has the notion of a member function pointer, which is independent of whatever object is used to call it. Such an object is provided when the member function is called

Which sounds right. But you said:

> The C++ pointer-to-member is a fairly confusing concept. What it actually is is a pair - a pointer to the instance of the struct, and a pointer to a function in that struct.

Which is neither consistent with that text nor with how C++ works. The D concept of a pointer to member is the fat pointer that encodes this. C++’s is the horrible lambda-ish thing that can find the method starting with any compatible this pointer. Yuck.


> But you said

Yeah, I miswrote it. Hence the link to my article about it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: