// Eksam.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include //#include "Karakter.h" #include #include #include #include using namespace std; //using namespace Game::Characters::Test; optional internetiOlek(bool e) { if (e) { return "Yhendus on olemas"; } return {}; } int main() { #pragma region Nested Namespaces //Karakter a = Karakter(15, "Joosep"); #pragma endregion #pragma region std::any naide cout << "----std::any naide" << endl; any x { 5.0 }; cout << any_cast(x) << endl; any_cast(x) = 10.2; cout << any_cast(x) << endl; cout << endl; cout << endl; #pragma endregion #pragma region Maps ja sets cout << "----Maps ja sets extract naide" << endl; map map1 { {1, "v6ti"}, {2, "telefon"}, {3, "raha"} }; map map2 { {4, "laptop"}, {5, "juhe"} }; map2.insert(map1.extract(map1.find(1))); map2.insert(map1.extract(2)); map2.insert(map1.extract(3)); for (int i = 1; i < 6; i++) { cout << map2.at(i) << " "; } cout << endl; cout << endl; std::map m{ { 1, "one" },{ 2, "two" },{ 3, "three" } }; auto e = m.extract(2); e.key() = 4; m.insert(move(e)); cout << m.at(1) << " "; cout << m.at(3) << " "; cout << m.at(4) << " "; cout << endl; cout << endl; #pragma endregion #pragma region Auto cout << "----auto vaartus muutujatele" << endl; auto x1{ 1 }; cout << x1 << endl; cout << endl; cout << endl; #pragma endregion #pragma region Auto lambda cout << "----Auto lambda" << endl; auto liitmine = [](auto x, auto y) { return x+y; }; auto three = liitmine(3.1,2); cout << three << endl; cout << endl; cout << endl; #pragma endregion #pragma region std::Variant cout << "----std::variant" << endl; variant v{ 13 }; cout << get(v) << endl; v = "tere"; cout << get(v) << endl; cout << endl; cout << endl; #pragma endregion #pragma region Optional cout << "----Optional" << endl; cout << internetiOlek(true).value() << endl; cout << internetiOlek(false).value_or("Yhendus puudub") << endl; #pragma endregion cout << endl; cout << endl; return 0; }