Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- char a[] = "zdarova";
- int b = 10;
- uint64_t c = 1488;
- long double d = 1337.228;
- char e[] = "korova";
- short f = 20;
- vector<pair<char, void*>> st = {
- { 'a', static_cast<void*>(&a) },
- { 'b', static_cast<void*>(&b) },
- { 'c', static_cast<void*>(&c) },
- { 'd', static_cast<void*>(&d) },
- { 'e', static_cast<void*>(&e) },
- { 'f', static_cast<void*>(&f) }
- };
- sort(st.begin(), st.end(),
- [&](auto& a, auto& b) {
- return a.second < b.second;
- }
- );
- for (auto& [first, second] : st) {
- cout << first << " : " << second << '\n';
- }
- return 0;
- }
- /*
- g++ -std=c++17 -O0
- f : 0x52cedff4c6
- e : 0x52cedff4c9
- d : 0x52cedff4d0
- c : 0x52cedff4e8
- b : 0x52cedff4f4
- a : 0x52cedff4f8
- g++ -std=c++17 -O2
- f : 0x1ecebffab2
- b : 0x1ecebffab4
- e : 0x1ecebffab9
- c : 0x1ecebffac0
- a : 0x1ecebffac8
- d : 0x1ecebffad0
- */
Add Comment
Please, Sign In to add comment