Commit 62bf5932 authored by Max Lyon's avatar Max Lyon

Merge branch 'mheistermann/OpenVolumeMesh-range-for'

parents 99bffb75 fc9ff0ce
Pipeline #3289 failed with stage
in 3 minutes and 21 seconds
......@@ -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 */>
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment