FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/include/boost/python/iterator.hpp at develop · BoostGSoC21/python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
BoostGSoC21
/
python
Public
forked from
boostorg/python
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
include
/
boost
/
python
/
iterator.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
135 lines (120 loc) · 4.21 KB
Breadcrumbs
python
/
include
/
boost
/
python
/
iterator.hpp
Copy path
File metadata and controls
135 lines (120 loc) · 4.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//
Copyright David Abrahams 2002.
//
Distributed under the Boost Software License, Version 1.0. (See
//
accompanying file LICENSE_1_0.txt or copy at
//
http://www.boost.org/LICENSE_1_0.txt)
#
ifndef
ITERATOR_DWA2002512_HPP
#
define
ITERATOR_DWA2002512_HPP
#
include
<
boost/python/detail/prefix.hpp
>
#
include
<
boost/python/detail/target.hpp
>
#
include
<
boost/python/detail/type_traits.hpp
>
#
include
<
boost/python/object/iterator.hpp
>
#
include
<
boost/python/object_core.hpp
>
#
if
defined(BOOST_MSVC) && (BOOST_MSVC == 1400)
/*
> warning C4180: qualifier applied to function type has no meaning; ignored
Peter Dimov wrote:
This warning is caused by an overload resolution bug in VC8 that cannot be
worked around and will probably not be fixed by MS in the VC8 line. The
problematic overload is only instantiated and never called, and the code
works correctly.
*/
#
pragma
warning(disable: 4180)
#
endif
#
include
<
boost/bind.hpp
>
#
include
<
boost/bind/protect.hpp
>
namespace
boost
{
namespace
python
{
namespace
detail
{
//
Adds an additional layer of binding to
//
objects::make_iterator(...), which allows us to pass member
//
function and member data pointers.
template
<
class
Target
,
class
Accessor1
,
class
Accessor2
,
class
NextPolicies
>
inline
object
make_iterator
(
Accessor1 get_start
, Accessor2 get_finish
, NextPolicies next_policies
, Target&(*)()
)
{
return
objects::make_iterator_function<Target>(
boost::protect
(
boost::bind
(get_start, _1))
,
boost::protect
(
boost::bind
(get_finish, _1))
, next_policies
);
}
//
Guts of template class iterators<>, below.
template
<
bool
const_ =
false
>
struct
iterators_impl
{
template
<
class
T
>
struct
apply
{
typedef
typename
T::iterator iterator;
static
iterator
begin
(T& x) {
return
x.
begin
(); }
static
iterator
end
(T& x) {
return
x.
end
(); }
};
};
template
<>
struct
iterators_impl
<
true
>
{
template
<
class
T
>
struct
apply
{
typedef
typename
T::const_iterator iterator;
static
iterator
begin
(T& x) {
return
x.
begin
(); }
static
iterator
end
(T& x) {
return
x.
end
(); }
};
};
}
//
An "ordinary function generator" which contains static begin(x) and
//
end(x) functions that invoke T::begin() and T::end(), respectively.
template
<
class
T
>
struct
iterators
: detail::iterators_impl<
detail::is_const<T>::value
>::
template
apply<T>
{
};
//
Create an iterator-building function which uses the given
//
accessors. Deduce the Target type from the accessors. The iterator
//
returns copies of the inderlying elements.
template
<
class
Accessor1
,
class
Accessor2
>
object
range
(Accessor1 start, Accessor2 finish)
{
return
detail::make_iterator
(
start, finish
,
objects::default_iterator_call_policies
()
,
detail::target
(start)
);
}
//
Create an iterator-building function which uses the given accessors
//
and next() policies. Deduce the Target type.
template
<
class
NextPolicies
,
class
Accessor1
,
class
Accessor2
>
object
range
(Accessor1 start, Accessor2 finish, NextPolicies* =
0
)
{
return
detail::make_iterator
(start, finish,
NextPolicies
(),
detail::target
(start));
}
//
Create an iterator-building function which uses the given accessors
//
and next() policies, operating on the given Target type
template
<
class
NextPolicies
,
class
Target
,
class
Accessor1
,
class
Accessor2
>
object
range
(Accessor1 start, Accessor2 finish, NextPolicies* =
0
, boost::type<Target>* =
0
)
{
//
typedef typename add_reference<Target>::type target;
return
detail::make_iterator
(start, finish,
NextPolicies
(), (Target&(*)())
0
);
}
//
A Python callable object which produces an iterator traversing
//
[x.begin(), x.end()), where x is an instance of the Container
//
type. NextPolicies are used as the CallPolicies for the iterator's
//
next() function.
template
<
class
Container
,
class
NextPolicies
= objects::default_iterator_call_policies>
struct
iterator
: object
{
iterator
()
: object(
python::range<NextPolicies>(
&iterators<Container>::begin, &iterators<Container>::end
))
{
}
};
}}
//
namespace boost::python
#
endif
//
ITERATOR_DWA2002512_HPP
Back
|
FazBrowse Home
|
New Git URL