aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/digest/lower_case/lciter.h
blob: 9538e57932c2f30f0d89812e46b344217e07771c (plain) (blame)
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
37
38
39
40
41
42
#pragma once

#include <util/generic/typetraits.h>
#include <util/string/ascii.h>

#include <iterator>

template <class T>
struct TLowerCaseIterator: public std::iterator<std::input_iterator_tag, T> {
    using TNonConst = std::remove_const_t<T>;

    inline TLowerCaseIterator(T* c)
        : C(c)
    {
    }

    inline TLowerCaseIterator& operator++() noexcept {
        ++C;

        return *this;
    }

    inline TLowerCaseIterator operator++(int) noexcept {
        return C++;
    }

    inline TNonConst operator*() const noexcept {
        return AsciiToLower(*C);
    }

    T* C;
};

template <class T>
inline bool operator==(const TLowerCaseIterator<T>& l, const TLowerCaseIterator<T>& r) noexcept {
    return l.C == r.C;
}

template <class T>
inline bool operator!=(const TLowerCaseIterator<T>& l, const TLowerCaseIterator<T>& r) noexcept {
    return !(l == r);
}