memesearch
C++ трюки и щитпост

C++ трюки и щитпост

Download Find similar pictures
Text on the meme
Антон Реасе++ @0xfe0d C++ трюки неотличимы от щитпоста. Читал код с мыслью: "В принципе смешно, но в чём именно шутка?". Дочитал и пришёл к выводу, что C++ - метамодерновый язык. Daisy Hollman @The_Whole_Daisy · 21 ч. Cute C++ trick of the day: Want to compare types with a more familiar syntax (like in Python, for instance)? A simple wrapper template can make this happen! You can even use function call syntax if you don't need co... 5 // Make a type with comparison operators based on its template parameter 6 template <class T> 7 struct TypeWrapper { 8 template <class U> 9 friend constexpr bool operator==(TypeWrapper, TypeWrapper<U>) { 10 return std::is_same_v<T, U>; 11 } 12 }; 13 template <class T> inline constexpr auto type = TypeWrapper<T>(); 14 template <class T> constexpr auto typeof(T) { return TypeWrapper<T>(); } 16 // Example use 17 template <class T, class U> 18 void test(T& a, U& b) { 19 if constexpr (decltype(b) == type<U>) { 20 assert(type<U> == typeof(T)); 21 std::cout << "same!\n"; 22 } 23 else std::cout << "different!\n"; 24 } 26 // demo 27 int main() { 28 test(42, 3.14); // "different!" 29 test("hello", "world"); // "same!" 30 }
What it means

На изображении показан пост Антона Реасе++ с цитатой о странном трюке на C++, где типы сравниваются через необычный шаблон-обёртку. Автор сначала принимает код за очередной щитпост, но дочитывает его и приходит к выводу, что сам C++ — метамодерновый язык. Это реакция на абсурдно сложный и одновременно забавный код, который выглядит как шутка, даже когда технически работает. EN: The image shows a post by Anton Реасе++ quoting a strange C++ trick in which types are compared through an unusual wrapper template. The author initially mistakes the code for another shitpost, but after reading it concludes that C++ itself is a metamodern language. It is used as a reaction to absurdly complex yet amusing code that looks like a joke even when it technically works.

Who
Objects
Tags
Source
Type
image
Size
431×800 · 80.8 KiB
Mood
абсурдный, саркастичный
Language
ru
Added