C++ constexpr // a tool for optimizing your code

preview_player
Показать описание
We continue our series on C++11 features you might have forgotten or never learned. This time, we learn about the constexpr keyword which can be used to tell the compiler to evaluate certain expressions at COMPILETIME. This will speed up the execution of your program, but at a cost.

// Learn More //
C++ 11 playlist:

Check out my complete C++ videos playlist:

// Consider supporting this channel in multiple ways //
Bitcoin: 177wfkQwzXiC8o2whQMVpSyuWUs95krKYB
Dogecoin: DRK2HDp3ZkkbFpvGZnVgMVosnBhPv8r3uP
Рекомендации по теме
Комментарии
Автор

Good video.
In a past I assumed that good compielrs optimise stuff like that on their own.

peterSobieraj
Автор

I'm using CLion c++17 and 4:26 this compile to me.... No need to use constexpr.... Thanks anyway

josepescina
Автор

hi professor, I took your class last semester and I would like to get a head start into CS201. What videos do you recommend I should watch and in what order? Thank you.

SagaLabsAI
Автор

Hi Professor,
I tried following the code but it got compiled without any issues.
int z = 5 + 2;
int a[z];
it has not raised any error with compile time or runtime. I am not sure how it occurred in your case. are these suppressed in later c++ compiler versions line14, 17, 20.

can you please guide

GSmileK
join shbcf.ru