aboutsummaryrefslogtreecommitdiff
path: root/cpp07/ex00/whatever.hpp
blob: 53953f86e7878071a3f9baea82cf80b95616d292 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   whatever.hpp                                       :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: charles <charles.cabergs@gmail.com>        +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/14 19:46:56 by charles           #+#    #+#             */
/*   Updated: 2020/12/15 11:08:51 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef WHATEVER_HPP
# define WHATEVER_HPP

template<typename T>
void swap(T& a, T& b)
{
    T tmp(a);
    a = b;
    b = tmp;
}

template<typename T>
T& min(T& a, T& b)
{
    return a < b ? a : b;
}

template<typename T>
T& max(T& a, T& b)
{
    return a > b ? a : b;
}

class NotAnInt
{
public:
    NotAnInt();
    NotAnInt(int n);
    NotAnInt(NotAnInt const& other);
    NotAnInt& operator=(NotAnInt const& other);

    bool operator==(NotAnInt const& other) const;
    bool operator!=(NotAnInt const& other) const;
    bool operator>(NotAnInt const& other) const;
    bool operator<(NotAnInt const& other) const;
    bool operator>=(NotAnInt const& other) const;
    bool operator<=(NotAnInt const& other) const;

    int getN() const;

private:
    int m_n;
};

std::ostream& operator<<(std::ostream& out, NotAnInt const& n);

#endif