Array Turns Into Set
#include <array> #include <set> #include <iostream> int main() { std::array<int, 5> a{ 0, 1, 2, 3, 4 }; auto s0 = std::set{a.begin(), a.end()}; auto s1 = std::set{a.begin(), a.end()}; std::cout << s0.size() << ": "; for (const auto& e: s0) std::cout << e << " "; std::cout << std::endl << s1.size() << ": "; for (const auto& e: s1) std::cout << e << " "; } ASM generation compiler returned: 0 Execution build compiler returned: 0 Program returned: 0 2: 0x7fff15fbe6d0 0x7fff15fbe6e4 5: 0 1 2 3 4
A C++ code screenshot shows two apparently identical constructions of std::set from the same array. The first line unexpectedly produces a set of two pointer-like values, while the second correctly produces five integers, joking about subtle C++ initializer-list and iterator behavior. It is used as a reaction to confusing, surprising, or repeatedly frustrating programming bugs.
#c++#programming#программирование#coding#кодинг#bug#баг#compiler#компилятор#std::set#std::array#iterators#итераторы#initializer list#список инициализации#unexpected behavior#неожиданное поведение#confusing#запутанно#frustration#раздражение#reaction#реакция#screenshot#скриншот#programming meme#мем про программирование
- @ithueti / 2248 2020-04-07
- Type
- image
- Size
- 660×800 · 82.8 KiB
- Mood
- confused, frustrated
- Language
- en
- Added