diff --git a/STL_Extension/include/CGAL/Iterator_range.h b/STL_Extension/include/CGAL/Iterator_range.h index e42441e9858..2c41f38266a 100644 --- a/STL_Extension/include/CGAL/Iterator_range.h +++ b/STL_Extension/include/CGAL/Iterator_range.h @@ -18,56 +18,36 @@ namespace CGAL { - /*! -\ingroup PkgSTLExtensionRef - /// `CGAL::Iterator_range` is a... - */ - template - class Iterator_range - : public std::pair{ +/*! + \ingroup PkgSTLExtensionRef + `CGAL::Iterator_range` encapsulates two iterators so they fulfill the `ForwardRange` concept. + The class is essentially a clone of `boost::iterator_range`, + and it additionally is derived from `std::pair`, so that one can apply `boost::tie`. +*/ +template +class Iterator_range : public std::pair +{ + typedef std::pair Base; - typedef std::pair Base; +public: + typedef I iterator; + typedef I const_iterator; - public: + Iterator_range() = default; + Iterator_range(I b, I e) + : Base(b, e) {} + Iterator_range(const std::pair& ip) + : Base(ip) {} - typedef I iterator; - typedef I const_iterator; - - Iterator_range(I b, I e) - : Base(b,e) - {} - - - // Iterator_range(const Iterator_range& ip) - // : Base(ip) - // {} - - Iterator_range(const std::pair& ip) - : Base(ip) - {} - - I begin() const - { - return this->first; - } - - I end() const - { - return this->second; - } + I begin() const { return this->first; } + I end() const { return this->second; } /// returns `std::distance(begin(), end())` - std::size_t - size() const - { - return static_cast(std::distance(begin(), end())); - } + std::size_t size() const { return static_cast(std::distance(begin(), end())); } /// returns `std::distance(begin(), end())==0` - bool empty() const - { - return begin()==end(); - } + bool empty() const { return begin() == end(); } operator std::tuple() { @@ -87,37 +67,25 @@ namespace CGAL { } }; - template - Iterator_range - make_range(const T& b, const T&e) - { - return Iterator_range(b,e); - } +template +Iterator_range +make_range(const T& b, const T&e) +{ + return Iterator_range(b,e); +} - template - Iterator_range - make_range(const std::pair& p) - { - return Iterator_range(p.first,p.second); - } +template +Iterator_range +make_range(const std::pair& p) +{ + return Iterator_range(p.first,p.second); +} } // namespace CGAL -// At global scope... - +namespace boost::foreach { template -inline boost::mpl::true_ * - boost_foreach_is_lightweight_proxy( CGAL::Iterator_range *&, boost::foreach::tag ) -{ - return 0; + struct is_lightweight_proxy> : boost::mpl::true_ {}; } -namespace boost { namespace foreach -{ - template - struct is_lightweight_proxy< CGAL::Iterator_range > - : mpl::true_ - { - }; -}} #endif // CGAL_ITERATOR_RANGE_H