Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 30s8 days 9 hours 54 minutes 30 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 30s8 days 9 hours 54 minutes 30 seconds.

Sign in to watch this lesson
Templates and Generic Programming · 3:55
What can the compiler do for us before the program runs? We watch a constexpr function get evaluated during the build, let if constexpr throw away the branch a type can't use, ask type traits questions about types, and use one to choose memcpy or an element loop, measuring the real difference on a Mac with and without optimisation. We finish with static_assert and C++20's constinit, which make the compiler check our assumptions.