简体   繁体   中英

Building an infinite range with range-v3

I am trying to build a range which produces infinite random points in a triangle. To do that, I am using CGAL, which already provides the functionality to generate the random points in a triangle.

        Triangle coarseTriangle = {v[0], v[1], v[2]};
        CGAL::Random_points_in_triangle_2<Point> randomSamplesGenerator(coarseTriangle);

However, CGAL::Random_points_in_triangle_2 returns an iterator. In order to produce a range, I need a sentinel which always return false. Is there any sentinel like that already in range-v3 or do I have to code one myself?

You can use std::unreachable_sentinel (Or ranges::unreachable from <range/v3/iterator/unreachable_sentinel.hpp> ):

        ranges::subrange randomSamplesRange(randomSamplesGenerator, ranges::unreachable);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM