C++ Template Metaprogramming Madness [Reflective Serialization]

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

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

  • @arthurprediger4054
    @arthurprediger4054 12 часов назад

    Oh, I missed this series last year :0. Went through it now and I love the Chili way of showing first the nonscalable way of solving the problem and then the better one. I definitely saw the build up for the better way coming up, but the actual solution was a big mistery until the last minute >

  • @solipsist644
    @solipsist644 21 день назад

    Happy new Year!
    Currently in the midst of your Intermediate C++ series (and having a great time), but already taking a look at what the future of the C++ journey holds.
    Thank you for the incredibly well-crafted tutorial series and hope you'll continue putting out new content!
    Though your health and family (and especially the newest addition ;)) should be the priority.

    • @ChiliTomatoNoodle
      @ChiliTomatoNoodle  21 день назад

      @@solipsist644 thanks for the kind words! There will always be new content :)

  • @DotcomL
    @DotcomL 22 дня назад

    Reflection solved the main issue which was forgetting about a member of the struct. Cereal supports NVP and it would be trivial to extend to it using reflection.
    For the template metaprogramming hacks, hmm I think I'd have gone the way of checking whether all my types are serializable with some static assert on the variant, and still manually add support for each one (add one line of the macro) to fix when it fails to compile. And here it would simply use the cereal method to check if it's serializable. Less hacky IMHO, and don't forget you will still need to add cereal includes if you serialize other "native" types.
    But there's a magic to getting it all done automatically as you did!
    Happy new year and thanks for this awesome channel.

    • @ChiliTomatoNoodle
      @ChiliTomatoNoodle  22 дня назад +1

      I like the namespace detection approach, but you can't deny that UB, however unlikely to actually blow up, leaves a bad taste in the mouth.
      Thanks for watching and happy new year to you as well!

  • @goobensteen
    @goobensteen 22 дня назад +1

    Another christmas miracle!

  • @PedroOliveira-sl6nw
    @PedroOliveira-sl6nw 22 дня назад +2

    And that is why I say that "C++ Templates" (the book) is the black magic book. Maybe it should be named "Templates of the Dark Arts"

  • @PedroOliveira-sl6nw
    @PedroOliveira-sl6nw 22 дня назад +1

    Wishing you a great 2025!

  • @SonicFan535
    @SonicFan535 22 дня назад

    Did you try using std::is_aggregate_v instead of std::is_class_v? Then there'd be much fewer types to exclude (if any). Also, maybe you could avoid the UB of injecting a function into std by checking for "move" or some other function that's already guaranteed to be in std (and hopefully nowhere else, since I can't think of a situation where you'd name your own single-argument function "move").

    • @ChiliTomatoNoodle
      @ChiliTomatoNoodle  22 дня назад +2

      is_aggregate is interesting. Would still need fixing up for stuff like std::pair. Using a pre-existing std function for the ADL is too risky though. E.g. for your example of "move", consider boost::move.
      Actually thinking about it, you could inject a template specialization (which is not UB) for something like std::hash, and use that for your ADL if you wanted to be 100% correct.

  • @aswinaswin5672
    @aswinaswin5672 22 дня назад

    Hey happy christmas and new year.
    I have some doubts. Iam very very new to your channel.
    Where should i start learning from your channel. I mean like which playlist should i start. Iam a beginner.

    • @ChiliTomatoNoodle
      @ChiliTomatoNoodle  21 день назад

      @@aswinaswin5672 beginner c++ playlist. Check wiki.planetchili.net

    • @aswinaswin5672
      @aswinaswin5672 21 день назад

      @@ChiliTomatoNoodle Thanks