Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenVolumeMesh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenVolumeMesh
OpenVolumeMesh
Commits
122b292b
Commit
122b292b
authored
Oct 20, 2016
by
Martin Heistermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for C++11 range-for for iterator pairs, cf issue
#1
parent
77d3df03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
src/OpenVolumeMesh/Core/Iterators.hh
src/OpenVolumeMesh/Core/Iterators.hh
+26
-0
src/Unittests/unittests_iterators.cc
src/Unittests/unittests_iterators.cc
+9
-0
No files found.
src/OpenVolumeMesh/Core/Iterators.hh
View file @
122b292b
...
...
@@ -130,6 +130,32 @@ private:
const
TopologyKernel
*
mesh_
;
};
#if __cplusplus >= 201103L
#include <type_traits>
template
<
class
I
>
using
is_ovm_iterator
=
std
::
is_base_of
<
BaseIterator
<
typename
std
::
remove_const
<
typename
I
::
value_type
>::
type
>
,
I
>
;
// provide begin() and end() for the iterator pairs provided in TopologyKernel,
// so we can use range-for, e.g. for(const auto &vh: mesh.vertices()) works.
template
<
class
I
>
typename
std
::
enable_if
<
is_ovm_iterator
<
I
>::
value
,
I
>::
type
begin
(
const
std
::
pair
<
I
,
I
>
&
iterpair
)
{
return
iterpair
.
first
;
}
template
<
class
I
>
typename
std
::
enable_if
<
is_ovm_iterator
<
I
>::
value
,
I
>::
type
end
(
const
std
::
pair
<
I
,
I
>
&
iterpair
)
{
return
iterpair
.
second
;
}
#endif // C++11
template
<
class
IH
/* Input handle type */
,
class
OH
/* Output handle type */
>
...
...
src/Unittests/unittests_iterators.cc
View file @
122b292b
...
...
@@ -22,3 +22,12 @@ TEST_F(HexahedralMeshBase, HexVertexIterTest) {
EXPECT_EQ
(
VertexHandle
(
5
),
*
hv_it
);
}
#if __cplusplus >= 201103L // C++11
TEST_F
(
HexahedralMeshBase
,
RangeForTest
)
{
// no EXPECTs here, if it compiles, it'll work.
generateHexahedralMesh
(
mesh_
);
for
(
const
auto
&
vh
:
mesh_
.
vertices
())
{}
const
auto
&
constref
=
mesh_
;
for
(
const
auto
&
vh
:
constref
.
vertices
())
{}
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment