From a929adc492abb4bd22844061a713a3227e4bd7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Sat, 21 Aug 2004 21:54:02 +0000 Subject: [PATCH] *** empty log message *** [SVN r24638] --- include/boost/range/iterator_range.hpp | 11 +++++++++++ test/sub_range.cpp | 2 ++ 2 files changed, 13 insertions(+) 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 ) ); }