[Dlang Episode 87] D Language - Templates - Part 4 of n - Struct Templates

Поділитися
Вставка
  • Опубліковано 25 чер 2024
  • ►Full DLang Series Playlist: • D Language (DLang) Pro...
    ►Find full courses on: courses.mshah.io/
    ►Join as member to get perks: / @mikeshah
    ►Lesson Description: In this lesson I we will continue discussing templates, this time showing you how to work with 'structs'. Templates really shine when creating data structures or records that you can use with different types. Later we'll get into cool stuff with 'template mixins', but for now the basics of setting up a struct with a template is very similar to a function. Similar tools also exist for using 'alias' for common types.
    ►Please like and subscribe to help the channel!
    ►UA-cam Channel: / mikeshah
    ►Join our free community: courses.mshah.io/communities/...
  • Наука та технологія

КОМЕНТАРІ • 9

  • @Chupe_chupe
    @Chupe_chupe 2 місяці тому +1

    Great video

  • @GaryChike
    @GaryChike 2 місяці тому +1

    First!!!

    • @MikeShah
      @MikeShah  2 місяці тому +1

      No one is challenging you yet -- that's three in a row!

  • @bsdooby
    @bsdooby 2 місяці тому +1

    I wonder why the type param `... = MyType!T(...)` is necessary for structs 🤔

    • @MikeShah
      @MikeShah  2 місяці тому +1

      I'm not sure if D has the same Class template argument deduction (CTAD) as in C++. I might have just missed it perhaps. But I suspect given the CTFE (compile-time function execution), and perhaps the difficulty of having multiple constructors that could conflict with type inference, it is simply a difficult problem -- not 100% sure though.

    • @bsdooby
      @bsdooby 2 місяці тому +1

      @@MikeShah 🙏 for taking the time to answer my question(s)!

    • @MikeShah
      @MikeShah  2 місяці тому

      @@bsdooby Of course -- thanks for being part of the community and discourse! D is a great language to learn the ins and outs of -- the questions help all (myself included)!