-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterator_experiment.cpp
More file actions
69 lines (55 loc) · 1.17 KB
/
iterator_experiment.cpp
File metadata and controls
69 lines (55 loc) · 1.17 KB
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
65
66
67
68
69
#include <iostream>
#include "type_traits/type_traits.hpp"
template<bool IsConst>
class MyIterator {
friend class MyIterator<true>;
//friend class MyIterator<false>;
int _d;
public:
MyIterator(void) : _d(1) {};
MyIterator(MyIterator<IsConst> const & src) : _d(2)
{
(void)src;
};
template<bool WasConst>
MyIterator(MyIterator<WasConst> const & src,
typename ft::enable_if<IsConst || !WasConst>::type * = 0) : _d(2)
{
(void)src;
};
~MyIterator(void) {};
/*MyIterator<IsConst> & operator=(MyIterator<IsConst> const & rhs)
{
if (this != &rhs)
this->_d = rhs._d;
return (*this);
};*/
MyIterator<IsConst> & operator=(MyIterator<false> const & rhs)
{
this->_d = rhs._d;
return (*this);
};
bool operator!=(MyIterator<IsConst> const& rhs)
{
return (this->_d != rhs._d);
};
bool operator==(MyIterator<IsConst> const& rhs)
{
return (!(this->_d != rhs._d));
};
int getD(void) const
{
return (this->_d);
};
};
int main(void)
{
MyIterator<false> it;
MyIterator<true> cit(it);
std::cout << cit.getD() << std::endl;
cit = it;
std::cout << cit.getD() << std::endl;
if (it == it)
std::cout << "yeah" << std::endl;
return (0);
}