main.cpp
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* main.cpp :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: gychoi <gychoi@student.42seoul.kr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2023/12/20 23:48:23 by gychoi #+# #+# */ 9 /* Updated: 2023/12/22 16:52:36 by gychoi ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #include <iostream> 14 #include "whatever.hpp" 15 16 void testFunc() 17 { 18 float f1 = 0.001f; 19 float f2 = 0.01f; 20 21 std::cout << "\n-------------------\n"; 22 std::cout << "[float]" << std::endl; 23 ::swap(f1, f2); 24 std::cout << "f1 = " << f1 << ", f2 = " << f2 << std::endl; 25 std::cout << "min(f1, f2) = " << ::min(f1, f2) << std::endl; 26 std::cout << "max(f1, f2) = " << ::max(f1, f2) << std::endl; 27 28 int const a = -2; 29 int const b = -3; 30 31 std::cout << "[const]" << std::endl; 32 std::cout << "Can't swap const value" << std::endl; 33 std::cout << "a = " << a << ", b = " << b << std::endl; 34 std::cout << "min(a, b) = " << ::min(a, b) << std::endl; 35 std::cout << "max(a, b) = " << ::max(a, b) << std::endl; 36 37 int volatile c = 4; 38 int volatile d = 5; 39 40 std::cout << "[volatile]" << std::endl; 41 ::swap(c, d); 42 std::cout << "c = " << c << ", d = " << d << std::endl; 43 std::cout << "min(c, d) = " << ::min(c, d) << std::endl; 44 std::cout << "max(c, d) = " << ::max(c, d) << std::endl; 45 46 int const volatile e = 6; 47 int const volatile f = 7; 48 49 std::cout << "[const volatile]" << std::endl; 50 std::cout << "Can't swap const value" << std::endl; 51 std::cout << "e = " << e << ", f = " << f << std::endl; 52 std::cout << "min(e, f) = " << ::min(e, f) << std::endl; 53 std::cout << "max(e, f) = " << ::max(e, f) << std::endl; 54 } 55 56 int main(void) { 57 58 int a = 2; 59 int b = 3; 60 61 ::swap(a, b); 62 std::cout << "a = " << a << ", b = " << b << std::endl; 63 std::cout << "min(a, b) = " << ::min(a, b) << std::endl; 64 std::cout << "max(a, b) = " << ::max(a, b) << std::endl; 65 66 std::string c = "chaine1"; 67 std::string d = "chaine2"; 68 69 ::swap(c, d); 70 std::cout << "c = " << c << ", d = " << d << std::endl; 71 std::cout << "min(c, d) = " << ::min(c, d) << std::endl; 72 std::cout << "max(c, d) = " << ::max(c, d) << std::endl; 73 74 testFunc(); 75 76 return 0; 77 }