C++ Compile Time Goes to Hell
C++ source #1 #include <cstdio> #include <range/v3/view/iota.hpp> #include <range/v3/view/take.hpp> #include <range/v3/view/transform.hpp> #include <range/v3/numeric/accumulate.hpp> using namespace std; namespace rv = ranges::view; namespace { namespace hs { auto sum() { return ranges::make_pipeable([](auto&& rng) { return ranges::accumulate(rng, 0); }); } } auto numberOfTwitterFollowers() -> int { auto v = { 4, 4, 44 }; return v | rv::transform([](auto i) { return rv::iota(1) | rv::take(i) | hs::sum(); }) | hs::sum(); } int main() { return numberOfTwitterFollowers(); } x86-64 clang (trunk) (Editor #1, Compiler #1) C++ -x86-64 clang (trunk) -std=c++2a -O2 main: mov eax, 1000 ret
A dark-theme Compiler Explorer screenshot shows dense C++ range-v3 code on the left and the tiny x86-64 clang assembly output on the right. The joke is that an absurdly elaborate implementation is used to calculate a simple result, echoing the uploader’s remark about Eric Niebler’s extremely intense libraries making compilation time come unglued. It is used as a reaction to overengineered C++ code, template-heavy libraries, or unexpectedly long compile times.
computer screen / экран компьютераcode editor / редактор кодаC++ source code / исходный код C++assembly output / вывод ассемблераdark theme / тёмная темаsplit-pane interface / интерфейс с разделёнными панелямиline numbers / номера строкsyntax highlighting / подсветка синтаксисаbrowser window / окно браузераcompiler panel / панель компилятораtext cursor / текстовый курсорscrollbar / полоса прокрутки
#c++#clang#compile time#время компиляции#compiler#компилятор#template metaprogramming#метапрограммирование шаблонов#overengineering#переусложнение#programming#программирование#code#код#assembly#ассемблер#range-v3#eric niebler#эрик ниблер#programmer humor#юмор программистов#reaction#реакция#screenshot#скриншот#tweet#твит
- @ithueti / 1281 2019-08-30
- Type
- image
- Size
- 800×558 · 54.9 KiB
- Mood
- саркастичный, абсурдный
- Language
- en
- Added