/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* whatever.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/14 19:46:56 by charles #+# #+# */ /* Updated: 2020/04/14 20:01:41 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include #include template void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; } template T& min(T& a, T& b) { return a < b ? a : b; } template T& max(T& a, T& b) { return a > b ? a : b; } int main() { int a = 2; int b = 3; ::swap(a, b); std::cout << "a = " << a << ", b = " << b << std::endl; std::cout << "min( a, b ) = " << ::min( a, b ) << std::endl; std::cout << "max( a, b ) = " << ::max( a, b ) << std::endl; std::string c = "chaine1"; std::string d = "chaine2"; ::swap(c, d); std::cout << "c = " << c << ", d = " << d << std::endl; std::cout << "min( c, d ) = " << ::min( c, d ) << std::endl; std::cout << "max( c, d ) = " << ::max( c, d ) << std::endl; return 0; }