Swap.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* Swap.hpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2026/01/09 14:08:45 by bchanot #+# #+# */
  9. /* Updated: 2026/01/09 15:26:46 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #ifndef SWAP_HPP
  13. # define SWAP_HPP
  14. # include <iostream>
  15. # include <string>
  16. template < typename T >
  17. void swap(T &x, T &y) {
  18. T temp;
  19. temp = x;
  20. x = y;
  21. y = temp;
  22. }
  23. template < typename T >
  24. T min(T const & x, T const & y) {
  25. return (x < y ? x : y);
  26. }
  27. template < typename T >
  28. T max(T const & x, T const & y) {
  29. return (x > y ? x : y);
  30. }
  31. #endif