-
Notifications
You must be signed in to change notification settings - Fork 1
/
insert_iterator.cpp
107 lines (92 loc) · 1.97 KB
/
insert_iterator.cpp
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include<algorithm>
#include<iostream>
#include<iterator>
#include<vector>
#include"../header/tool/CInsert_iterator.hpp"
using namespace std;
struct A
{
void set(const int &)
{
cout<<"const int &"<<endl;
}
};
struct B
{
void set(const int &)
{
cout<<"const int &"<<endl;
}
void set(int &&)
{
cout<<"int &&"<<endl;
}
};
struct C
{
template<class T>
void set(T &&)
{
cout<<"T &&"<<endl;
}
};
template<class T>
struct D
{
void set(const T &)
{
cout<<"const T &"<<endl;
}
};
template<class T>
struct E
{
void set(const T &)
{
cout<<"const T &"<<endl;
}
void set(T &&)
{
cout<<"T &&"<<endl;
}
};
template<class T>
struct F
{
template<class T2>
void set(T2 &&)
{
cout<<"T2 &&"<<endl;
}
};
int main()
{
A a;
B b;
C c;
D<int> d;
E<int> e;
F<double> f;
vector<int> vec{1};
copy(begin(vec),end(vec),nTool::inserter<int,void(A::*)(const int &),&A::set>(a));
copy(begin(vec),end(vec),nTool::inserter<int,
void(B::*)(const int &),&B::set,
void(B::*)(int &&),&B::set>(b));
copy(make_move_iterator(begin(vec)),make_move_iterator(end(vec)),nTool::inserter<int,
void(B::*)(const int &),&B::set,
void(B::*)(int &&),&B::set>(b));
copy(begin(vec),end(vec),nTool::inserter<int,
void(C::*)(const int &),&C::set<const int &>,
void(C::*)(int &&),&C::set<int>>(c));
copy(begin(vec),end(vec),nTool::inserter<int,
void(D<int>::*)(const int &),&D<int>::set>(d));
copy(begin(vec),end(vec),nTool::inserter<int,
void(E<int>::*)(const int &),&E<int>::set,
void(E<int>::*)(int &&),&E<int>::set>(e));
copy(make_move_iterator(begin(vec)),make_move_iterator(end(vec)),nTool::inserter<int,
void(E<int>::*)(const int &),&E<int>::set,
void(E<int>::*)(int &&),&E<int>::set>(e));
copy(begin(vec),end(vec),nTool::inserter<int,
void(F<double>::*)(const int &),&F<double>::set<const int &>,
void(F<double>::*)(int &&),&F<double>::set<int>>(f));
}