diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp index ee10e37..4469be9 100755 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -191,6 +192,16 @@ namespace boost { // iterator range free-standing operators ---------------------------// + template< class Iterator > + inline bool empty( const iterator_range& r ) + { + // + // this will preserve the well-defined empty() even + // though 'r' is singular. + // + return r.empty(); + } + //! iterator_range output operator /*! Output the range to an ostream. Elements are outputed diff --git a/test/sub_range.cpp b/test/sub_range.cpp index 5fefb30..cba6c14 100755 --- a/test/sub_range.cpp +++ b/test/sub_range.cpp @@ -121,6 +121,8 @@ void check_iterator_range() BOOST_CHECK( singular_srange.empty() ); BOOST_CHECK( singular_srange.size() == 0 ); + BOOST_CHECK( empty( singular_irange ) ); + BOOST_CHECK( empty( singular_srange ) ); }