Basically, I want to make a hava wrapper in some abstract class, and then include the same wrapper class around the output of any member function of this class. Continue to do this so that all objects are always wrapped.
How (overcodes)
wrap<set(1..10)> (multiply,2)
(divide,3)
(plus,5)
(inverse)
(collect first 10)
.unwrap()
All lines except the last line output something. At the moment, this will seem less, but I believe that we can apply interesting things to it, for example:
wrap<someClass> dat;
dat.splitIntoThreads(2)
(thingA) .clone()
(thingB) (thing1)
(thingC) (thing2)
(thingD) (thing3)
.nothing() (thing4)
.sync() .exit()
.addMerge()
Here is my transfer code:
template<class T>
struct wrap{
wrap(){}
wrap(T b){a=b;}
template<class L,class...R>
L operator() (L(T::*f)(R...),R...r){
return a.f(r...);
}
T a;
};
int main(){
wrap<testClass> a;
a(&testClass::f,13,'a');
}
Works (gcc, C ++ 0x). But when I replace the 6,7th line with the following (to actually wrap the result)
wrap<L> operator() (L(T::*f)(R...),R...r){
return wrap<L>(a.f(r...));
The compiler is simply sais: creates a pointer to a member function of a non-class class of type "int".
? ? , , , .
struct testClass{
int f(int a,char b){
return a+b;
}
};
, wrap L wrap T, , T.