C++ Template Metaprogramming Chaos
C++ programmers: modern C++ is really nice and readable Also C++ programmers: template <typename... T> requires std::is_same_v<int, T...[0] && requires(T...[0]) { { T...[0]() } -> std::same_as<T...[0]>; } struct S : T...[1] { [no_unique_address] T...[1] base = {}; using foo = T...[1]; S() // : T...[1]() { static_assert(std::is_same_v<int, T...[0]>); const T...[0] f(T...[0] & noexpect(T...[0][0]) { T...[0] (*test)(const volatile T...[0]*); thread_local T...[0] d; [[maybe_unused]] T...[0] a = p; return a; auto ptr = new T...[0](); using Int = int; (*ptr)->T...[0](); return T...[0](); typename T...[1]::foo b = 0; T...[1]::i = 0; return T...[0](a); new T...[0]; new T...[0]*&a); auto l = [](T...[0]>(T...[0][1]) -> T...[0]{return static_cast<T...[0]>(0);}; [[maybe_unused]] auto _ = template operator()<T...[0]>({0}); } operator T...[0]() const{ } }; struct base { using foo = int; static inline int i = 42; }; int main() { S<int, base>().f(0); ///////////// }
The meme contrasts the claim that modern C++ is readable with an intentionally absurd block of template-heavy code. The joke is that advanced C++ programmers can write syntax so complicated that it becomes nearly impossible to understand. It is commonly sent as a reaction to overengineered code or arguments about C++ simplicity.
C++ source code / исходный код C++black background / чёрный фонwhite text / белый текстcode editor screenshot / скриншот редактора кодаtemplate syntax / синтаксис шаблоновstruct definition / определение структурыcolored code highlighting / цветная подсветка кодаmain function / функция mainprogramming comments / комментарии в коде
- @profunctor_io / 8341 2022-10-12
- @dev_meme / 4928 2022-10-12
- @right_wing_dev_squads / 5362 2022-11-23
- Type
- image
- Size
- 692×800 · 77.6 KiB
- Mood
- sarcastic, absurd
- Language
- en
- Added