CppCon 2016: Vittorio Romeo “Implementing `static` control flow in C++14'

preview_player
Показать описание


There has always been great interest in imperative compile-time control flow: as an example, consider all the existing `static_if` proposals and the recently accepted `constexpr_if` construct for C++17.

What if you were told that it is actually possible to implement imperative control flow in C++14?

In this tutorial, the implementation and design of a compile-time `static_if` branching construct and of a compile-time `static_for` iteration construct will be shown and analyzed. These constructs will then be compared to traditional solutions and upcoming C++17 features, examining advantages and drawbacks.

Vittorio Romeo
Bloomberg LP
Software Engineer
London, UK
Vittorio Romeo is an Italian 21 year old Computer Science student at "Università degli Studi di Messina". He began programming at a very young age and is now a C++ enthusiast. While following the evolution of the C++ standard and embracing the newest features, he worked on several open-source projects, including modern general-purpose libraries and free cross-platform indie games. Vittorio is an active member of the C++ community: he participated as a speaker at CppCon 2014/2015, ++it Florence 2015 and at his local Linux Day 2013/2014 events, as a Student/Volunteer at C++Now 2015, and as part of Meeting C++ 2015's student program. He currently maintains a YouTube channel featuring well-received modern C++11 and C++14 tutorials. When he's not writing code, Vittorio enjoys weightlifting and fitness-related activities, competitive/challenging computer gaming and good scifi movies/TV-series.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Sad to see people disliking. Keep on rocking, Vittorio!

IvanBudiselic
Автор

Thank you for saying STD. So much "stood" is driving me crazy.

Fetrovsky
Автор

31:41 You didn't mention one key point why this works.
The n that is passed to the lambda is not an integer value or some non-type template argument, it is an instance of std::integral_constant. The reason you can use it as a constant expression in buffer<n> to specify the buffer size is because integral_constant has a constexpr cast operator to the integer type it wraps, returning its wrapped value. I was pretty amazed that this works.

sanjuuyonsai
Автор

When you talked about why we can't use [&x]{...} I wondered, to make it more useable with multiple variables you could pass in a dummy-variable instead and just capture everything by reference. Then every lambda would just be [&](auto){...} and the call would be with any dummy value - the compiler optimizing it away naturally. But that is of course a problem of the user.

worldsender
Автор

Unregistered Sublime? Not cool, not cool.

dawikur