C++ Type Erasure Demystified - Fedor G Pikus - C++Now 2024

Поділитися
Вставка
  • Опубліковано 28 гру 2024

КОМЕНТАРІ • 16

  • @dimitrioskantakouzinos8590
    @dimitrioskantakouzinos8590 5 місяців тому +18

    Always love talks by Fedor Pikus.

  • @GeorgeTsiros
    @GeorgeTsiros 5 місяців тому +7

    Fedor! Good to see him still do presentations.

  • @pancio-ciancio
    @pancio-ciancio 3 місяці тому

    Wow thanks. Need to rewatch it because is a complex topic for me. I recognize the work behind the presentation.

  • @quicklilac
    @quicklilac 5 місяців тому +1

    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!

    • @llothar68
      @llothar68 3 місяці тому

      But if the comparison is not simple int/float comparison it is not. But creates more code, lot more code

  • @CanIHaveSomeMore
    @CanIHaveSomeMore 5 місяців тому +2

    So Type Erasure is just passing function pointers?

  • @leanidchaika
    @leanidchaika 5 місяців тому +1

    Nice!

  • @trk03t123
    @trk03t123 Місяць тому

    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.

  • @Roibarkan
    @Roibarkan 6 місяців тому +2

    1:17:29 Eduardo Madrid on thecppzoo: ua-cam.com/video/s082Qmd_nHs/v-deo.html

  • @Tinfoilpain
    @Tinfoilpain 3 місяці тому

    std::function is really great but I wish it had proper allocator support 😢

  • @sanjaygatne1424
    @sanjaygatne1424 5 місяців тому

    Type Eraser video with different title. Same video uploaded..

  • @rocknroooollllll
    @rocknroooollllll 20 днів тому

    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
    @josephlunderville3195 5 місяців тому +1

    It's PIMPL!

    • @Roibarkan
      @Roibarkan 5 місяців тому +2

      @@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.

    • @llothar68
      @llothar68 3 місяці тому

      @@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