Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <random>
- bool WrongCompare(int a, int b) {
- return a <= b; // UB
- }
- void f(std::mt19937& gen) {
- std::uniform_int_distribution<> uid(0, 10);
- std::vector<int> items(30);
- std::cout << "input: ";
- for (auto& value : items) {
- value = uid(gen);
- std::cout << value << " ";
- }
- std::cout << std::endl;
- sort(items.begin(), items.end(), WrongCompare);
- std::cout << "result: ";
- for (const int x : items) {
- std::cout << x << " ";
- }
- std::cout << std::endl;
- }
- int f(int x);
- int g() {
- return f(1);
- }
- std::vector<int> z() {
- return {};
- return std::vector<int>();
- }
- std::pair<int, double> func() {
- return {1, 3.14};
- return std::make_pair(1, 3.14);
- return std::pair<int, double>(1, 3.14);
- }
- std::tuple<int, char, double> func2() {
- std::tuple<int, char, double> z(1, 'a', 3.14);
- std::get<0>(z) = 10;
- return z;
- }
- struct Type {
- double y;
- int z;
- };
- Type func3() {
- return Type{1, 3.14};
- }
- std::vector<int> func4() {
- return {1,2,3,4};
- }
- int main() {
- auto [x, y] = func();
- auto [q, w, y] = func2();
- auto [p, z] = func3();
- //auto [a1,a2,a3,a4] = func4(); CE
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement