Your New Mental Model of constexpr - Jason Turner - CppCon 2021

Your New Mental Model of constexpr - Jason Turner - CppCon 2021

CppCon

2 года назад

59,222 Просмотров

https://cppcon.org/
https://github.com/CppCon/CppCon2021
---
In my experience as a trainer, YouTuber, and speaker, I find that many people have a mistaken impression of what constexpr is and for what it is suited. I see people over-complicate constexpr by conflating it with meta programming and template-related topics. Students will often fail to recognize where and when constexpr could be used. Experts will get concerned about the "contract" you are making with the user of your library by marking functions as constexpr.

In this talk, I will present a mental model for how you should consider constexpr. I will explain what constexpr is (less mechanically and more metaphorically), give practical applications for constexpr, and help you figure out where constexpr fits into your application or library.

In the most straightforward sense, constexpr is moving work from runtime to compile-time. This mental model that I will present will ask, "what work would you rather do at compile-time?" We will find this answer by looking at constexpr as a continuum. On one end of the continuum is the use case of moving a runtime fixed-size vector into a compile-time fixed-size constexpr array, and on the far end is executing your entire program at compile-time and simply outputting the results at runtime.

---
Jason Turner

Host of C++Weekly https://www.youtube.com/c/JasonTurner-lefticus, Co-host of CppCast http://cppcast.com, Co-creator and maintainer of the embedded scripting language for C++, ChaiScript http://chaiscript.com, and author and curator of the forkable coding standards document http://cppbestpractices.com.

I'm available for contracting and onsite training.

---
Videos Filmed & Edited by Bash Films: http://www.BashFilms.com

YouTube Channel Managed by Digital Medium Ltd https://events.digital-medium.co.uk

*--*

Тэги:

#c++_talk #c++_talk_video #cpp_talk #cpp_talk_video #c++ #cpp #cppcon #c++con #cpp_con #c++_con #c++_tutorial #c++_workshop #learn_cpp #learn_c++ #programming #coding #software #software_development #cppcon_2021 #bash_films #constexpr_c++ #constexpr_c++20 #constexpr_function_c++ #how_to_use_constexpr #how_to_use_constexpr_in_c++ #constexpr_example #cppcon_constexpr #why_use_constexpr #jason_turner #jason_turner_cppcon #jason_turner_c++ #jason_turner_c++_weekly
Ссылки и html тэги не поддерживаются


Комментарии: