19:15 this is not the only thing. I would say another big thing is that std::sort is actually faster than qsort (which is a big deal), and this is thanks to compilers being able to inline comparison. UPD: Great talk!
There is a Bug in slide 37. If void operator(void* ptr) {d_(static_cast(p))} is done then with smartptr_te widgetPtr = smartptr_re(new widget(), [](auto p){ delete p; }) above "widgetPtr" will be called for d_(static_cast(p)) which is not correct. Real type erasure is deleter function with whatever param as such will be templated and stored internally at COMPILE time. No lazy cast while invoking the deleter. IMO. GCC have a test static_assert(__is_invocable::value, "deleter expression d(p) is well-formed"); _Yp is of type widget and not Void.
Usual crowd of know-it-alls with unwelcome contributions -- clearly unsettling Fedor. I do wish they wouldn't. It may be collegial but its bad for posterity on the videos! Perhaps the comments should be edited out? I do like Fedor's talks though. Excellent exposition.
@@josephlunderville3195 Indeed that structure looks very much like the pimpl idiom, but the concept is different. In pimpl the idea is to hide implementation details but all implementations are the same (pointer is used to decouple the single class implementation from the various users), and type erasure is meant to support many implementations (sharing an interface) - even ones unknown to the original designer of the interface.
@@Roibarkan There are multiple use cases for pimpl. including switching the implementation (class type) at runtime which you can't do with C++. I tried to switch vtable pointers once, but while working, code review team got heart attacks. Pimpl just means redirecting function calls
Always love talks by Fedor Pikus.
Fedor! Good to see him still do presentations.
Wow thanks. Need to rewatch it because is a complex topic for me. I recognize the work behind the presentation.
19:15 this is not the only thing. I would say another big thing is that std::sort is actually faster than qsort (which is a big deal), and this is thanks to compilers being able to inline comparison.
UPD: Great talk!
But if the comparison is not simple int/float comparison it is not. But creates more code, lot more code
So Type Erasure is just passing function pointers?
Nice!
Thanks!
There is a Bug in slide 37. If
void operator(void* ptr) {d_(static_cast(p))} is done then with
smartptr_te widgetPtr = smartptr_re(new widget(), [](auto p){ delete p; })
above "widgetPtr" will be called for d_(static_cast(p)) which is not correct.
Real type erasure is deleter function with whatever param as such will be templated and stored internally at COMPILE time. No lazy cast while invoking the deleter. IMO.
GCC have a test
static_assert(__is_invocable::value, "deleter expression d(p) is well-formed");
_Yp is of type widget and not Void.
1:17:29 Eduardo Madrid on thecppzoo: ua-cam.com/video/s082Qmd_nHs/v-deo.html
std::function is really great but I wish it had proper allocator support 😢
Type Eraser video with different title. Same video uploaded..
Usual crowd of know-it-alls with unwelcome contributions -- clearly unsettling Fedor. I do wish they wouldn't. It may be collegial but its bad for posterity on the videos! Perhaps the comments should be edited out? I do like Fedor's talks though. Excellent exposition.
It's PIMPL!
@@josephlunderville3195 Indeed that structure looks very much like the pimpl idiom, but the concept is different. In pimpl the idea is to hide implementation details but all implementations are the same (pointer is used to decouple the single class implementation from the various users), and type erasure is meant to support many implementations (sharing an interface) - even ones unknown to the original designer of the interface.
@@Roibarkan There are multiple use cases for pimpl. including switching the implementation (class type) at runtime which you can't do with C++. I tried to switch vtable pointers once, but while working, code review team got heart attacks. Pimpl just means redirecting function calls