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

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

Комментарии • 15

  • @dimitrioskantakouzinos8590
    @dimitrioskantakouzinos8590 4 месяца назад +17

    Always love talks by Fedor Pikus.

  • @GeorgeTsiros
    @GeorgeTsiros 4 месяца назад +7

    Fedor! Good to see him still do presentations.

  • @pancio-ciancio
    @pancio-ciancio 2 месяца назад

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

  • @quicklilac
    @quicklilac 4 месяца назад +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 2 месяца назад

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

  • @trk03t123
    @trk03t123 12 дней назад

    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.

  • @CanIHaveSomeMore
    @CanIHaveSomeMore 4 месяца назад +2

    So Type Erasure is just passing function pointers?

  • @Tinfoilpain
    @Tinfoilpain 2 месяца назад

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

  • @leanidchaika
    @leanidchaika 4 месяца назад +1

    Nice!

  • @sanjaygatne1424
    @sanjaygatne1424 4 месяца назад

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

  • @Roibarkan
    @Roibarkan 5 месяцев назад +2

    1:17:29 Eduardo Madrid on thecppzoo: ruclips.net/video/s082Qmd_nHs/видео.html

  • @josephlunderville3195
    @josephlunderville3195 4 месяца назад +1

    It's PIMPL!

    • @Roibarkan
      @Roibarkan 4 месяца назад +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 2 месяца назад

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