|
Boost : |
From: Mat Marcus (mmarcus_at_[hidden])
Date: 2001-12-15 16:57:53
>I think that a compile-time port of boost.bind would be a valuable addition
>to MPL.
>
>See the end of the message for a starting point. This works on MSVC; a full
>port with nested binds and a bind<> syntax (not the numbered bind0, bind1,
>... variants) would be possible, too, and is actually not difficult on a
>conforming compiler. On MSVC it'd be a bit harder, but doable.
>
>Comments?
Peter,
Cool. Now I have a question. In the runtime version of bind it seems
like I can do something like this (borrowed from bind_as_compose.cpp):
template<class F> void test(F f)
{
std::cout << f("x", "y") << '\n';
}
std::string f(std::string const & x)
{
return "f(" + x + ")";
}
std::string f(std::string x);
test( bind(f, _1) );
// emits "f(x)"
That is, bind helps me avoid the use of compose_f_gxy and project1st.
I would like to do the same thing at compile time. For example, I
would like to replace:
mpl::compose_f_gxy<
RightParent
, :mpl::project1st<mpl::_1, mpl::_2>
>
with something like:
bind2<RightParent, _1>
Can you see how to do this?
- Mat
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk