LeechCraft
0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
views.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
namespace
LC::Util::Views
12
{
13
namespace
detail
14
{
15
template
<
template
<
typename
,
typename
>
class
PairType
,
typename
I1
,
typename
I2
>
16
struct
ZipIterator
17
{
18
I1
It1_
;
19
const
I1
It1End_
;
20
I2
It2_
;
21
const
I2
It2End_
;
22
23
bool
operator==
(
const
ZipIterator
&
other
)
const
24
{
25
if
(
IsSentinel
() ||
other
.IsSentinel ())
26
return
IsSentinel
() ==
other
.IsSentinel ();
27
28
return
It1_
==
other
.It1_ &&
It2_
==
other
.It2_;
29
}
30
31
bool
IsSentinel
()
const
32
{
33
return
It1_
==
It1End_
||
It2_
==
It2End_
;
34
}
35
36
auto
&
operator++
()
37
{
38
++
It1_
;
39
++
It2_
;
40
return
*
this
;
41
}
42
43
auto
&
operator++
(
int
)
44
{
45
auto
it
= *
this
;
46
47
++
It1_
;
48
++
It2_
;
49
50
return
it
;
51
}
52
53
auto
operator*
()
const
54
{
55
return
PairType
{ *
It1_
, *
It2_
};
56
}
57
};
58
}
59
60
template
<
template
<
typename
,
typename
>
class
PairType
=
QPair
,
typename
C1
,
typename
C2
>
61
auto
Zip
(
C1
&&
c1
,
C2
&&
c2
)
62
{
63
using
ZIt
=
detail::ZipIterator<PairType, typename std::decay_t<C1>::const_iterator
,
typename
std::decay_t<C2>::const_iterator>;
64
struct
Range
65
{
66
C1 C1_;
67
C2 C2_;
68
69
auto
begin ()
const
{
return
ZIt { C1_.cbegin (), C1_.cend (), C2_.cbegin (), C2_.cend () }; }
70
auto
end ()
const
{
return
ZIt { C1_.cend (), C1_.cend (), C2_.cend (), C2_.cend () }; }
71
};
72
73
return
Range
{ std::forward<C1> (
c1
), std::forward<C2> (
c2
) };
74
}
75
}
LC::Util::Views
Definition
views.h:12
LC::Util::Views::Zip
auto Zip(C1 &&c1, C2 &&c2)
Definition
views.h:61
LC::Util::Filter
Container< T > Filter(const Container< T > &c, F f)
Definition
prelude.h:118
LC::Util::Views::detail::ZipIterator
Definition
views.h:17
LC::Util::Views::detail::ZipIterator::operator++
auto & operator++()
Definition
views.h:36
LC::Util::Views::detail::ZipIterator::It2_
I2 It2_
Definition
views.h:20
LC::Util::Views::detail::ZipIterator::It1_
I1 It1_
Definition
views.h:18
LC::Util::Views::detail::ZipIterator::operator==
bool operator==(const ZipIterator &other) const
Definition
views.h:23
LC::Util::Views::detail::ZipIterator::IsSentinel
bool IsSentinel() const
Definition
views.h:31
LC::Util::Views::detail::ZipIterator::It2End_
const I2 It2End_
Definition
views.h:21
LC::Util::Views::detail::ZipIterator::It1End_
const I1 It1End_
Definition
views.h:19
LC::Util::Views::detail::ZipIterator::operator*
auto operator*() const
Definition
views.h:53
LC::Util::detail::Filter
Definition
typelist.h:103
src
util
sll
views.h
Generated by
1.10.0