-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClosures.h
More file actions
51 lines (37 loc) · 898 Bytes
/
Closures.h
File metadata and controls
51 lines (37 loc) · 898 Bytes
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
/*
* File: Closures.h
* Author: AMEZIANE NAIT ABDELAZIZ
*
* Created on 4 novembre 2011, 20:04
*/
#ifndef CLOSURES_H
#define CLOSURES_H
#include <iostream>
using namespace std;
namespace Functional{
template <typename IN,typename OUT> class Routine {
public:
virtual OUT invok(IN& arg)=0;
//void *(*routine_addr) (void* arg)=0;
virtual ~Routine(){
cout << "deleting default instance"<<endl;
}
};
/**
* Classe fonction
*/
template <typename IN,typename OUT > class Function{
Routine<IN,OUT>* routine;
public:
Function(Routine<IN,OUT>* r){
this->routine = r;
}
OUT operator () (IN arg){
return this->routine->invok(arg);
}
~Function(){
//delete routine;
}
};
}
#endif /* CLOSURES_H */