C++ From Scratch: Constexpr

2022 ж. 16 Жел.
7 232 Рет қаралды

In this video we look at the basics of compile-time programming in C++ with constexpr!
C++ Reference: en.cppreference.com/w/cpp/lan...
For code samples: github.com/coffeebeforearch
For live content: / coffeebeforearch

Пікірлер
  • Awesome explanation. Especially with showing the assembly. constexpr finally makes sense for me.

    @Martial_Monkey@Martial_Monkey6 ай бұрын
  • Very clear explanation. Appreciate it!

    @daveamiana3957@daveamiana395714 күн бұрын
  • Great work man. I've been following the daily series for a week now and I really like the explanations with examples, and it's been nice revising concepts!

    @a-r-r-o-w@a-r-r-o-w Жыл бұрын
    • Thank you! Glad you have enjoyed them! :^)

      @CoffeeBeforeArch@CoffeeBeforeArch Жыл бұрын
  • Hey nick! I have been following this series and learned so many things. Your ability to explain the concepts is amazing. Thank you very much!

    @deoabhijit5935@deoabhijit5935 Жыл бұрын
    • Glad you’re enjoying the videos! :^)

      @CoffeeBeforeArch@CoffeeBeforeArch Жыл бұрын
  • Best explanation with nice examples. Getting back to C++ after a while and like your video a lot. The depth, examples and the way you present it are all nice. Thanks!

    @sameda9698@sameda96985 ай бұрын
    • In the video, the program is build in debug mode. Which disable optimisations. If the non constexpr code is built in release mode, there is a high chance that the result is calculated at compile time. I think

      @marcjukil300@marcjukil3003 ай бұрын
  • Hey I've been watching you for a while and I just noticed that you're now making C++ videos daily! I'm really glad that you're teaching C++ the modern way instead of starting from raw pointers in C like most people do, this is really helpful for people that are starting with C++ in the modern world using modern syntax I'm really looking forward to more advanced modern features in C++20 in the future if you plan to do them, like ranges and template parameter pack because I've been out of the C++ loop for a while now 😂

    @vintagewander@vintagewander Жыл бұрын
    • Thanks! Glad you are liking the videos. This series is nearing its end (I think I want to checkpoint this as an intro course to C++, rather than keep it going indefinitely), but I will be starting a couple more series. One catering more toward software development with C++ (where more of the niche C++ features will go, along with topics like debuggers and build systems), and another more heavily focused on parallel programming with C++. Cheers, --Nick

      @CoffeeBeforeArch@CoffeeBeforeArch Жыл бұрын
  • Very interesting asm extractions, thank you very much

    @VoidloniXaarii@VoidloniXaarii8 ай бұрын
  • Great work! Very good explanation!

    @TKcKoucher@TKcKoucher4 ай бұрын
  • Very nice explanation, thanks

    @protheu5@protheu510 ай бұрын
  • Amazing video. Thank you so much!!!

    @joshbolton2782@joshbolton27829 ай бұрын
  • Thanks. It was a useful example.

    @hilium3000@hilium30008 ай бұрын
  • your way of explanation is great , thanks a lot . would you kindly explain how would the assembly look like at the last stage / what is the performance effects ?

    @fw3mbedded598@fw3mbedded5983 ай бұрын
  • Great video! Was really helpful in answering some of my doubts regarding compile time and runtime. I was wondering whether you could make a video about iterators?

    @gavinvasandani5560@gavinvasandani5560 Жыл бұрын
    • I have a basic video on iterators that was earlier in the series - kzhead.info/sun/YMuQaMWlr3WkpYU/bejne.html Was there something else that you wanted covered?

      @CoffeeBeforeArch@CoffeeBeforeArch Жыл бұрын
  • damn well explained, thanks man!

    @gaborharangozo1587@gaborharangozo15878 ай бұрын
  • Thanks!

    @mikemota@mikemota3 ай бұрын
  • Hi Nick, your terminal looks very nice, which one you are using? Thx!

    @nikcname@nikcname5 ай бұрын
    • zsh with the agnoster theme

      @CoffeeBeforeArch@CoffeeBeforeArch5 ай бұрын
  • Why can't the compiler just do the right thing without this feature? It has the same information about the code as you do to accomplish this goal.

    @SnakeEngine@SnakeEngine5 ай бұрын
  • This is another point where C++ annoys me. I get that they didn't want to reuse an old keyword and change its behavior, but they should have anyway. I don't know if it would have broken any older C++ programs that used inline lazily, but since I use g++ I don't care. I take the approach here that if it would have broken any old code then that code was likely wrong anyhow. In fact, I'd dare say that const and inline should have both been changed and constexpr is just a dumb keyword. Anyone else agree?

    @anon_y_mousse@anon_y_mousse Жыл бұрын
    • One of C++'s strongest points is its strong backwards compatibility. The python2 -> python3 fiasco would be huge in the C++ world due to the sheer size of code out there.

      @sledgex9@sledgex93 ай бұрын
    • @@sledgex9 And I maintain that breaking such code would be fine because they're likely using the preexisting keyword wrong anyhow. If something is labelled const, it should be const, not some quasi-const nonsense.

      @anon_y_mousse@anon_y_mousse3 ай бұрын
KZhead