C++ Weekly - Ep 6 Intro To Variadic Templates

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

КОМЕНТАРІ • 61

  • @planetmuman
    @planetmuman 4 роки тому +8

    nm has an option '-C' which automatically demangles the C++ names.

  • @graham12345dd
    @graham12345dd 2 роки тому +3

    Excellent. I explored this feature about 12 months ago but was working with legacy code since so no chance to dive back in. The code;
    return { to_string(param)... };
    is the part that caught my eye. (param)... those dots! :) I'll continue on with this series, its exactly whats needed to get this stuff understood (for me anyways). Watching compile time, symbol table and exe size, glaringly obvious but not something I have observed. Its now in my box of tools! :)
    Thank YOU!

  • @mytech6779
    @mytech6779 7 років тому +8

    Year and a half late, I could go for a 2-4 point increase in editor font. Otherwise great stuff, concise, good explanation, and nice pace.
    So many other videos either run through so fast your mind is occupied just attempting to unpack the words or they go off into the weeds and waste a bunch of time on trivial aspects often barely touching on the fundamental components.

    • @SonaliProgrammingHub
      @SonaliProgrammingHub 2 роки тому

      Variadic Templates Function in C++11:
      ua-cam.com/video/bHoQBOjW_8k/v-deo.html

  • @surajkukreja5338
    @surajkukreja5338 3 роки тому +1

    About the increase in size of exe when using generic lambdas, cud it be due to every function call having local copy of lambda object, what if we passed that lambda by reference to generic to_string.

  • @sandeepchandappillai9814
    @sandeepchandappillai9814 8 років тому +4

    This is so cool ! Thanks Jason !

    • @SonaliProgrammingHub
      @SonaliProgrammingHub 2 роки тому

      Variadic Templates Function in C++11:
      ua-cam.com/video/bHoQBOjW_8k/v-deo.html

  • @almighty1984
    @almighty1984 10 місяців тому

    Very useful, glad I stumbled upon this video

  • @chrisminnoy3637
    @chrisminnoy3637 2 роки тому

    Something that seems overlooked in the standard is when using the 'using' keyword. You can't use the ... expansion operator on the variadic list when you want to expose for example a specific function which is available in all the types of the variadic template list.

    • @cppweekly
      @cppweekly  2 роки тому

      That was added in C++17 ua-cam.com/video/1gNzhE-Tn40/v-deo.html

  • @raducusmir9059
    @raducusmir9059 5 років тому +10

    c++17 one-liner without lambdas:
    _template_
    _const auto to_string(const Param& ... param)_
    _{_
    _return std::vector{ (std::stringstream()

    • @sinanlin7471
      @sinanlin7471 4 роки тому +1

      why it is compilable to cast an rvalue to a reference type? my mind exploded

    • @DrumMeister
      @DrumMeister 2 роки тому

      This cast is indeed strange but needed. @@sinanlin7471 You get this error: "error: 'class std::basic_ostream' has no member named 'str'". Incredible :-/

  • @stockdaleroger
    @stockdaleroger 26 днів тому

    Have any application for variadic templates in development , thank you !

  • @dshvets1
    @dshvets1 6 років тому +3

    g++ 7.2 produces less executable size with generic lambda ...

  • @MrVermond
    @MrVermond 5 років тому +10

    Would it be possible to use any ide, so you can see your code errors right away instead of wasting so much time to switch between vim and terminal.

    • @climatechangedoesntbargain9140
      @climatechangedoesntbargain9140 5 років тому +9

      But vim is so cool

    • @vertigo6982
      @vertigo6982 4 роки тому

      You'll be amazed at the power of the vim force. With some tinkering and some basic vim knowledge of running shell commands from inside vim one can execute commands and redirect the output to split windows. vim.fandom.com/wiki/Display_output_of_shell_commands_in_new_window

    • @Lensr
      @Lensr Рік тому

      Or just, ya know, another terminal window...

  • @Blaqkmagic1
    @Blaqkmagic1 8 років тому +8

    Possibly the creation of the different functor classes for the generic lambda resulted in the increased program size?

    • @pranvk
      @pranvk 7 років тому +3

      You mean to say that if we are calling to_string_impl with 5 different parameters, then 5 different lambdas will be created? I have read somewhere that 'auto' uses the template deduction itself, so sort of makes sense. And obviously it won't show up in the symbol table unlike normal template function because it's inside the function scope.

  • @arpitmaiya
    @arpitmaiya 4 роки тому +5

    Nice explanation, can you please post a session for factory design patterns in c++ ?

    • @SonaliProgrammingHub
      @SonaliProgrammingHub 2 роки тому

      Variadic Templates Function in C++11:
      ua-cam.com/video/bHoQBOjW_8k/v-deo.html

  • @weegreenblobbie
    @weegreenblobbie 7 років тому +12

    Thanks for the great video. Did you know nm -C will demangle C++ for you?

    • @SonaliProgrammingHub
      @SonaliProgrammingHub 2 роки тому

      Variadic Templates Function in C++11:
      ua-cam.com/video/bHoQBOjW_8k/v-deo.html

  • @treyquattro
    @treyquattro 4 роки тому +1

    that was good, particularly not having a canned response before you started. I find variadics and fold expressions very confusing, much more difficult to understand than C's original vararg idiom. I haven't tried this myself yet, but how does the compiler manage to return a vector of strings without apparently doing any allocations or push_backs?

    • @SonaliProgrammingHub
      @SonaliProgrammingHub 2 роки тому

      Variadic Templates Function in C++11:
      ua-cam.com/video/bHoQBOjW_8k/v-deo.html

    • @treyquattro
      @treyquattro 2 роки тому +1

      @@SonaliProgrammingHub sorry, I didn't find that at all useful. It didn't tell me anything that I don't already know and it was mostly reiterating very basic concepts. Good luck.

    • @SonaliProgrammingHub
      @SonaliProgrammingHub 2 роки тому

      @@treyquattro This is Part1 of variadic template function, I still I haven't completed this feature, might be when u go through part2 & part2, you might be finding useful.Thank you for feedback

    • @UsernameUsername0000
      @UsernameUsername0000 Рік тому

      I’m a beginner so I may be hugely misunderstanding the question and take my response with a grain of salt, but
      1) return { whatever }; is shorthand for return ReturnType{ whatever };
      2) std::vector has a constructor accepting an std::initializer_list, which I’m assuming (???) is what is being called here. I don’t think it’s any different than typing something like std::vector{ 3, 5, 9 } or std::vector a = {‘a’, ‘n’}. You typically only need push_back when you want to populate your vector after construction. Otherwise, many std::vector constructor overloads exist to populate the vector right as its constructed.

  • @BloganProgramming
    @BloganProgramming 2 роки тому

    Please, tell me, what is this font you're using in this terminal? Looks awesome! I couldn't find it by myself.

  • @ksawery2843
    @ksawery2843 3 роки тому +1

    Thanks, very helpful, although it took me some additional reading on Stack Overflow to understand the recursion.

    • @SonaliProgrammingHub
      @SonaliProgrammingHub 2 роки тому

      Variadic Templates Function in C++11:
      ua-cam.com/video/bHoQBOjW_8k/v-deo.html

  • @adamhunyadi345
    @adamhunyadi345 7 років тому

    I just revisited this old video and your series was cool back then too. Doesn't your long template perform an unnecessary copy in each recursion?

    • @learpcss9569
      @learpcss9569 3 роки тому

      yea, basically this function has O(n^2) complexity

  • @ANCIENTASTRONAUT
    @ANCIENTASTRONAUT 4 роки тому

    Thanks!

  • @tsto-ne2968
    @tsto-ne2968 2 роки тому

    Thank you.

  • @danielphd5072
    @danielphd5072 6 років тому +1

    Thank you

  • @guillermotomasini
    @guillermotomasini 5 років тому

    very clear, thanks.

  • @mustafakhozemadholkawala7548
    @mustafakhozemadholkawala7548 4 роки тому +1

    Very Good Video sir...... Lekin kuuch samjh nahi aya....

  • @alexstone691
    @alexstone691 6 років тому

    I think newer version of nm or gcc lambdas are symbols

  • @gordian99
    @gordian99 5 років тому

    Very helpful.

  • @tushar_g7796
    @tushar_g7796 6 років тому +1

    what is use of forward(param)... ?

    • @VladimirKrivopalov
      @VladimirKrivopalov 6 років тому +4

      This allows you to preserve the reference-qualification of parameters as they are passed in originally. Lvalues will be passed as lvalues and rvalues as rvalues.

  • @lllllltar
    @lllllltar 4 роки тому

    Thanks

  • @jony7779
    @jony7779 4 місяці тому

    I can't believe that I wasted brain cells learning this shit early in my programming career.

  • @karunesh26march
    @karunesh26march 4 роки тому

    very good example . though i have seen this earlier but again its still cool

  • @SonaliProgrammingHub
    @SonaliProgrammingHub 2 роки тому

    Variadic Templates Function in C++11:
    ua-cam.com/video/bHoQBOjW_8k/v-deo.html

  • @xriccardo1831
    @xriccardo1831 6 років тому +3

    Java is betr

    • @raducusmir9059
      @raducusmir9059 5 років тому +13

      Java vs. C++? ...You really have no idea what you're talking about.

    • @u7development547
      @u7development547 5 років тому +5

      i guess you are talking about the Java island .. isn´t ?

    • @wahabfiles6260
      @wahabfiles6260 4 роки тому +1

      u must be android developer. lol

    • @xriccardo1831
      @xriccardo1831 4 роки тому +1

      @@raducusmir9059 i was joking lol

    • @nallid7357
      @nallid7357 4 роки тому

      Java is an amazing coffee.