Но есть же constexpr
Но есть же constexpr... C++11 constexpr void LessThan10(int a,bool check) { if (check) assert(a < 10); }
На изображении показан фрагмент кода C++11 с функцией constexpr LessThan10, которая при включённой проверке утверждает, что число меньше 10. Шутка в том, что проверку можно было выполнить уже на этапе компиляции с помощью constexpr, но она фактически зависит от флага check и выглядит как избыточная оптимизация. EN: The image shows a C++11 code fragment with a constexpr function called LessThan10 that asserts a number is less than 10 when checking is enabled. The joke is that the check could already be performed at compile time using constexpr, but it actually depends on the check flag and looks like an overengineered optimization.
- @ithueti / 842 2019-04-19
- Type
- image
- Size
- 800×566 · 23.2 KiB
- Mood
- саркастичный
- Language
- ru
- Added