Boost logo

Boost :

From: shunsuke (pstade.mb_at_[hidden])
Date: 2008-01-12 16:49:35

Hi, all.

In a recent discussion, a library named Egg
possibly left a good impression on boosters, so I propose it.

    It is not so easy to define FunctionObjects
    especially if you want to support Boost.ResultOf and Boost.Lambda.
    Therefore, as Boost provides iterator_facade and iterator adaptors,
    Egg provides function_facade and function adaptors.

Egg provides the following features:

    * Helpers to build FunctionObject:
        * egg::function and egg::function_facade provides the way to
          build FunctionObject which supports Boost.ResultOf and Lambda.

    * FunctionObject Adaptors(in other words, higher-order functions):
        * egg::curryN supports the currying.
        * egg::pipable emulates extension methods(C#).
        * egg::fuse emulates variadic templates in very limited way.
        * etc...

The zipped source code is in Vault/FunctionObjects:
The document is on line:
svn repository:
Tested under:
  trunk and Boost1.34.1.

An example of currying in Egg:

    int plus(int x, int y)
        return x + y;

    typedef result_of_curry2<int (*)(int, int)>::type T_curried_plus;
    T_curried_plus const curried_plus = BOOST_EGG_CURRY2(&::plus);

    void test()
        BOOST_CHECK( curry2(&::plus)(4)(9) == 13 );
        BOOST_CHECK( curried_plus(4)(9) == plus(4, 9) );
        BOOST_CHECK( uncurry(curry2(plus))(4, 9) == 13 );

If interested enough, it might be enqueued to the review queue.
Anyway, comments are most welcome.


Shunsuke Sogame

Boost list run by bdawes at, gregod at, cpdaniel at, john at