Manu343726 / snail

Continuation-ready container algorithms from STL algorithms
MIT License
60 stars 4 forks source link

Tag dispatching for algorithm factories #4

Closed Manu343726 closed 9 years ago

Manu343726 commented 9 years ago

I think the templates used for algorithm factories (The actual functors to translate STL algorithms to container algorithms) are a bit verbose, where a simple tag dispatching approach may work:

template<typename Algorithm>
auto algorithm_factory(Algorithm algorithm, snail::categories::unary_inmutable)
{
    return [=](auto f)
    {
        return [=](const auto& container) -> decltype(container)
        {
            using std::begin;
            using std::end;
            algorithm( begin(container), end(container), f);

            return container;
        };
    };
}