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
|
template<class, class>
class Curve;
template<class T, class U, class V>
Curve<T,V> compose(const Curve<U,V>&, const Curve<T,U>&);
template<class T, class U>
class Curve
{
std::function<U (T)> f;
Space<T> s;
public:
template<class F, class S>
Curve(F f, S s) : f(f), s(s) {}
template<class S>
Space<U> image(S) const
{ /*algo 1*/ }
template<class S>
Space<T> solution(S) const
{ /*algo 2*/ }
Space<T> definition() const
{ return s; }
template<class V>
friend Curve<T,V> compose(const Curve<U,V>&, const Curve&);
template<class V>
friend Curve<V,U> compose(const Curve&, const Curve<V,T>&);
};
template<class T, class U, class V>
class ComposeF
{
std::function<U (T)> rhs;
std::function<V (U)> lhs;
public:
template<class F1, class F2>
ComposeF(F1 lhs, F3 rhs) : rhs(rhs), lhs(lhs) {}
V operator()(T t) const
{ return lhs(rhs(t)); }
};
template<class T, class U, class V>
Curve<T,V> compose(const Curve<U,V>& lhs, const Curve<T,U>& rhs)
{ return Curve<T,V>(ComposeF(lhs.f,rhs.f),rhs.s); } |