#include <boost/lambda/bind.hpp>
#include <boost/lambda/construct.hpp>
#include <boost/lambda/lambda.hpp>
#include <algorithm>
namespace L = boost::lambda;
namespace poost {
template <typename T>
inline const
L::lambda_functor<
L::lambda_functor_base<
L::action<1, L::function_action<1> >,
typename L::detail::bind_tuple_mapper<const L::new_ptr<T> >::type
>
>
new_ptr() {
return L::bind(L::new_ptr<T>());
}
template <typename T_lambda_functor>
inline const
L::lambda_functor<
L::lambda_functor_base<
L::action<2, L::function_action<2> >,
typename L::detail::bind_tuple_mapper<const L::delete_ptr, const T_lambda_functor>::type
>
>
delete_ptr(const T_lambda_functor& a_lf) {
return L::bind(L::delete_ptr(), a_lf);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
int* ints[10];
// lambda, what for?
std::for_each( ints, ints+10, L::_1 = L::bind(L::new_ptr<int>()) );
std::for_each( ints, ints+10, L::bind(L::delete_ptr(), L::_1) );
// awkward...
std::for_each( ints, ints+10, L::_1 = poost::new_ptr<int>() );
std::for_each( ints, ints+10, poost::delete_ptr(L::_1) );
// std::for_each(ints, ints+10, L::delete_ptr());
return 0;
}