1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include <iterator><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "snippet/aliases.hpp"
#include "internal/dev_env.hpp"
#include "internal/types.hpp"

#include "internal/auto_holder.hpp"


namespace uni {


template<class T, class Container = dynamic_auto_holder<T, internal::size_t>>
struct counter : Container {
    counter() noexcept(NO_EXCEPT) = default;

    template<std::input_iterator I, std::sentinel_for<I> S>
    counter(I first, S last) noexcept(NO_EXCEPT) {
        for(auto itr = first; itr != last; ++itr) ++(*this)[*itr];
    }

    template<std::ranges::input_range R>
    explicit counter(R&& range) noexcept(NO_EXCEPT) : counter(ALL(range)) {}
};


template<std::input_iterator I, std::sentinel_for<I> S>
explicit counter(I, S) -> counter<std::iter_value_t<I>>;

template<std::ranges::input_range R>
explicit counter(R) -> counter<std::ranges::range_value_t<R>>;


} // namespace uni