|
Boost Users : |
Subject: [Boost-users] [Proto] Higher order function
From: noman javed (noman_bwp_at_[hidden])
Date: 2010-04-27 12:31:49
Hi
I have just started experimenting with proto. I have the following grammer
G ::= Apply f G | Arrray
where the code of the simple array and apply classes are given below: How can I transform this code in the proto
template<typename T>
class Array
{
public:
Array(int size) : size(size)
{
data = new T[size];
}
operator=() { ... }
private:
int size;
T* data;
};
I have another class apply that applies the function (its first argument) on its other arguments
template<typename F, typename EXP>
struct apply
{
Array<typename F::result_type>& operator()(EXP & exp)
{ ... }
typename F::result_type operator[](typename F::input_type i)
{
return f(i);
}
};
The Apply class can be a unary or binary or infact an n-ary class.
How can I protofy this expression template?
Regards
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net