Boost.Lambda or Boost.Phoenix has great Boost Libraries that make a long way in making C ++ really A functional language but is there a simple way to create an overall function from any 2 or more arbitrary tasks or files?
If I have: int f (int x)
and int g (int x)
, I want to do something like f . G
which statically generates a new function object equal to f (g (x)).
It is possible through various techniques, such as those discussed. Of course, you can call a chain from boost :: lambda :: bind
to create a composite factor, but there is nothing in Boost that lets you easily take 2 or more functions or function objects. And allows them to combine to create a single composite factor, as you would in a language like Haskell?
I do not know anything that currently supports the syntax you want though, make one For this, it will be a simple matter for just Factors * Override * (boost :: function & lt;> for example) so that it returns a mixed factor
template & lt; Typename r1, typename r2, typename t1, typename t2> boost :: function & lt; R1 (t2)> operator * (boost :: function & lt; r1 (t2)> const & f, boost :: function & lt; r2 (t2)> const & g) {return boost :: bind (f, boost) :: Bind (G, _1)); }
Unchecked, but I suspect that if it does not work out of the box, then it is close.
Comments
Post a Comment