<commit_before>#ifndef containers_hh_INCLUDED
#define containers_hh_INCLUDED

#include <algorithm>
#include <utility>
#include <iterator>

namespace Kakoune
{

template<typename Factory>
struct ContainerView { Factory factory; };

template<typename Container, typename Factory>
auto operator| (Container&& container, ContainerView<Factory> view) ->
    decltype(view.factory(std::forward<Container>(container)))
{
    return view.factory(std::forward<Container>(container));
}

template<typename Container>
struct ReverseView
{
    using iterator = decltype(std::declval<Container>().rbegin());

    iterator begin() { return m_container.rbegin(); }
    iterator end()   { return m_container.rend(); }

    Container m_container;
};

template<typename C>
using RemoveReference = typename std::remove_reference<C>::type;

struct ReverseFactory
{
    template<typename Container>
    ReverseView<RemoveReference<Container>> operator()(Container&& container) const
    {
        return {std::move(container)};
    }

    template<typename Container>
    ReverseView<Container&> operator()(Container& container) const
    {
        return {container};
    }
};

inline ContainerView<ReverseFactory> reverse() { return {}; }

template<typename Container>
using IteratorOf = decltype(std::begin(std::declval<Container>()));

template<typename Container>
using ValueOf = typename Container::value_type;

template<typename Container, typename Filter>
struct FilterView
{
    using ContainerIt = IteratorOf<Container>;

    struct Iterator : std::iterator<std::forward_iterator_tag,
                                    typename ContainerIt::value_type>
    {
        Iterator(const FilterView& view, ContainerIt it, ContainerIt end)
            : m_it{std::move(it)}, m_end{std::move(end)}, m_view{view}
        {
            do_filter();
        }

        auto operator*() -> decltype(*std::declval<ContainerIt>()) { return *m_it; }
        Iterator& operator++() { ++m_it; do_filter(); return *this; }
        Iterator operator++(int) { auto copy = *this; ++(*this); return copy; }

        friend bool operator==(const Iterator& lhs, const Iterator& rhs)
        {
            return lhs.m_it == rhs.m_it;
        }

        friend bool operator!=(const Iterator& lhs, const Iterator& rhs)
        {
            return not (lhs == rhs);
        }

        const ContainerIt& base() const { return m_it; }

    private:
        void do_filter()
        {
            while (m_it != m_end and not m_view.m_filter(*m_it))
                ++m_it;
        }

        ContainerIt m_it;
        ContainerIt m_end;
        const FilterView& m_view;
    };

    Iterator begin() const { return {*this, std::begin(m_container), std::end(m_container)}; }
    Iterator end()   const { return {*this, std::end(m_container), std::end(m_container)}; }

    Container m_container;
    Filter m_filter;
};

template<typename Filter>
struct FilterFactory
{
    template<typename Container>
    FilterView<Container&, Filter> operator()(Container& container) const { return {container, std::move(m_filter)}; }

    template<typename Container>
    FilterView<RemoveReference<Container>, Filter> operator()(Container&& container) const { return {std::move(container), std::move(m_filter)}; }

    Filter m_filter;
};

template<typename Filter>
inline ContainerView<FilterFactory<Filter>> filter(Filter f) { return {{std::move(f)}}; }

template<typename I, typename T>
using TransformedResult = decltype(std::declval<T>()(*std::declval<I>()));

template<typename Container, typename Transform>
struct TransformView
{
    using ContainerIt = IteratorOf<Container>;

    struct Iterator : std::iterator<std::forward_iterator_tag,
                                    typename std::remove_reference<TransformedResult<ContainerIt, Transform>>::type>
    {
        Iterator(const TransformView& view, ContainerIt it)
            : m_it{std::move(it)}, m_view{view} {}

        auto operator*() -> TransformedResult<ContainerIt, Transform> { return m_view.m_transform(*m_it); }
        Iterator& operator++() { ++m_it; return *this; }
        Iterator operator++(int) { auto copy = *this; ++m_it; return copy; }

        friend bool operator==(const Iterator& lhs, const Iterator& rhs)
        {
            return lhs.m_it == rhs.m_it;
        }

        friend bool operator!=(const Iterator& lhs, const Iterator& rhs)
        {
            return not (lhs == rhs);
        }

        ContainerIt base() const { return m_it; }

    private:
        ContainerIt m_it;
        const TransformView& m_view;
    };

    Iterator begin() const { return {*this, std::begin(m_container)}; }
    Iterator end()   const { return {*this, std::end(m_container)}; }

    Container m_container;
    Transform m_transform;
};

template<typename Transform>
struct TransformFactory
{
    template<typename Container>
    TransformView<Container&, Transform> operator()(Container& container) const { return {container, std::move(m_transform)}; }

    template<typename Container>
    TransformView<RemoveReference<Container>, Transform> operator()(Container&& container) const { return {std::move(container), std::move(m_transform)}; }

    Transform m_transform;
};

template<typename Transform>
inline ContainerView<TransformFactory<Transform>> transform(Transform t) { return {{std::move(t)}}; }

template<typename Container, typename Separator = ValueOf<Container>,
         typename ValueTypeParam = void>
struct SplitView<commit_msg>Make container wrapper callback functions mutable<commit_after>#ifndef containers_hh_INCLUDED
#define containers_hh_INCLUDED

#include <algorithm>
#include <utility>
#include <iterator>

namespace Kakoune
{

template<typename Factory>
struct ContainerView { Factory factory; };

template<typename Container, typename Factory>
auto operator| (Container&& container, ContainerView<Factory> view) ->
    decltype(view.factory(std::forward<Container>(container)))
{
    return view.factory(std::forward<Container>(container));
}

template<typename Container>
struct ReverseView
{
    using iterator = decltype(std::declval<Container>().rbegin());

    iterator begin() { return m_container.rbegin(); }
    iterator end()   { return m_container.rend(); }

    Container m_container;
};

template<typename C>
using RemoveReference = typename std::remove_reference<C>::type;

struct ReverseFactory
{
    template<typename Container>
    ReverseView<RemoveReference<Container>> operator()(Container&& container) const
    {
        return {std::move(container)};
    }

    template<typename Container>
    ReverseView<Container&> operator()(Container& container) const
    {
        return {container};
    }
};

inline ContainerView<ReverseFactory> reverse() { return {}; }

template<typename Container>
using IteratorOf = decltype(std::begin(std::declval<Container>()));

template<typename Container>
using ValueOf = typename Container::value_type;

template<typename Container, typename Filter>
struct FilterView
{
    using ContainerIt = IteratorOf<Container>;

    struct Iterator : std::iterator<std::forward_iterator_tag,
                                    typename ContainerIt::value_type>
    {
        Iterator(const FilterView& view, ContainerIt it, ContainerIt end)
            : m_it{std::move(it)}, m_end{std::move(end)}, m_view{view}
        {
            do_filter();
        }

        auto operator*() -> decltype(*std::declval<ContainerIt>()) { return *m_it; }
        Iterator& operator++() { ++m_it; do_filter(); return *this; }
        Iterator operator++(int) { auto copy = *this; ++(*this); return copy; }

        friend bool operator==(const Iterator& lhs, const Iterator& rhs)
        {
            return lhs.m_it == rhs.m_it;
        }

        friend bool operator!=(const Iterator& lhs, const Iterator& rhs)
        {
            return not (lhs == rhs);
        }

        const ContainerIt& base() const { return m_it; }

    private:
        void do_filter()
        {
            while (m_it != m_end and not m_view.m_filter(*m_it))
                ++m_it;
        }

        ContainerIt m_it;
        ContainerIt m_end;
        const FilterView& m_view;
    };

    Iterator begin() const { return {*this, std::begin(m_container), std::end(m_container)}; }
    Iterator end()   const { return {*this, std::end(m_container), std::end(m_container)}; }

    Container m_container;
    mutable Filter m_filter;
};

template<typename Filter>
struct FilterFactory
{
    template<typename Container>
    FilterView<Container&, Filter> operator()(Container& container) const { return {container, std::move(m_filter)}; }

    template<typename Container>
    FilterView<RemoveReference<Container>, Filter> operator()(Container&& container) const { return {std::move(container), std::move(m_filter)}; }

    Filter m_filter;
};

template<typename Filter>
inline ContainerView<FilterFactory<Filter>> filter(Filter f) { return {{std::move(f)}}; }

template<typename I, typename T>
using TransformedResult = decltype(std::declval<T>()(*std::declval<I>()));

template<typename Container, typename Transform>
struct TransformView
{
    using ContainerIt = IteratorOf<Container>;

    struct Iterator : std::iterator<std::forward_iterator_tag,
                                    typename std::remove_reference<TransformedResult<ContainerIt, Transform>>::type>
    {
        Iterator(const TransformView& view, ContainerIt it)
            : m_it{std::move(it)}, m_view{view} {}

        auto operator*() -> TransformedResult<ContainerIt, Transform> { return m_view.m_transform(*m_it); }
        Iterator& operator++() { ++m_it; return *this; }
        Iterator operator++(int) { auto copy = *this; ++m_it; return copy; }

        friend bool operator==(const Iterator& lhs, const Iterator& rhs)
        {
            return lhs.m_it == rhs.m_it;
        }

        friend bool operator!=(const Iterator& lhs, const Iterator& rhs)
        {
            return not (lhs == rhs);
        }

        ContainerIt base() const { return m_it; }

    private:
        ContainerIt m_it;
        const TransformView& m_view;
    };

    Iterator begin() const { return {*this, std::begin(m_container)}; }
    Iterator end()   const { return {*this, std::end(m_container)}; }

    Container m_container;
    mutable Transform m_transform;
};

template<typename Transform>
struct TransformFactory
{
    template<typename Container>
    TransformView<Container&, Transform> operator()(Container& container) const { return {container, std::move(m_transform)}; }

    template<typename Container>
    TransformView<RemoveReference<Container>, Transform> operator()(Container&& container) const { return {std::move(container), std::move(m_transform)}; }

    Transform m_transform;
};

template<typename Transform>
inline ContainerView<TransformFactory<Transform>> transform(Transform t) { return {{std::move(t)}}; }

template<typename Container, typename Separator = ValueOf<Container>,
         typename ValueTypeParam = void>
struct SplitView
{'fraction_non_alphanumeric': 0.1250679717237629, 'fraction_numerical': 0.0, 'mean_word_length': 3.7037510656436488, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2049781', 'n_tokens_mistral': 3187, 'n_tokens_neox': 3056, 'n_words': 748}