blob: 8118060d2e4944aa6ba2dd0a7475dab1e1784a20 (
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
60
61
62
63
64
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* iter.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/14 15:06:48 by cacharle #+# #+# */
/* Updated: 2020/12/15 11:23:16 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ITER_HPP
# define ITER_HPP
# include <iostream>
template<typename T>
void iter(T* ptr, size_t len, void (*f)(T const& x))
{
for (size_t i = 0; i < len; i++)
f(ptr[i]);
}
template<typename T>
void iter(T* ptr, size_t len, void (*f)(T& x))
{
for (size_t i = 0; i < len; i++)
f(ptr[i]);
}
template<typename T>
void iter(T* ptr, size_t len, void (*f)(T x))
{
for (size_t i = 0; i < len; i++)
f(ptr[i]);
}
template<typename T>
void timeTwo(T const& x)
{
std::cout << "timeTwo function " << x << " * 2 = " << x * 2 << std::endl;
}
template<typename T>
void timeThree(T& x)
{
std::cout << "timeThree function " << x << " * 3 = " << x * 3 << std::endl;
}
class NotAnInt
{
public:
NotAnInt();
NotAnInt(int n);
NotAnInt(NotAnInt const& other);
NotAnInt& operator=(NotAnInt const& other);
int getN() const;
private:
int m_n;
};
#endif
|