diff --git a/include/boost/range/istream_range.hpp b/include/boost/range/istream_range.hpp index fac17a4..f0e9ef4 100755 --- a/include/boost/range/istream_range.hpp +++ b/include/boost/range/istream_range.hpp @@ -16,19 +16,24 @@ */ #include +#include #include -#include +#include namespace boost { - template inline - range > - istream_range(std::basic_istream& in) - { - return range >( - std::istream_iterator(in), - std::istream_iterator()); - } + namespace range + { + template inline + iterator_range > + istream_range(std::basic_istream& in) + { + return iterator_range >( + std::istream_iterator(in), + std::istream_iterator()); + } + } // namespace range + using range::istream_range; } // namespace boost #endif // include guard diff --git a/include/boost/range/unbounded_range.hpp b/include/boost/range/unbounded_range.hpp deleted file mode 100755 index 570a0a4..0000000 --- a/include/boost/range/unbounded_range.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef BOOST_RANGE_UNBOUNDED_RANGE_HPP -#define BOOST_RANGE_UNBOUNDED_RANGE_HPP - -#include -#include - -namespace boost -{ - template< class Iter > - struct unbounded_iterator_range : iterator_range - { - explicit unbounded_iterator_range( Iter r ) - : iterator_range( r, r ) - { - // - // Remark: by storing the same iterator - // twice, we can still allow - // comparison to execute without leading to - // operations on singular iterators - // - } - - private: - - bool empty() const - { - return false; - } - // - // Hide members that are illegal to use. - // - /* - void end() const; - void size() const; - void empty() const; - void equal() const; - operator bool() const; - bool operator==( unbounded_iterator_range ); - bool operator!=( unbounded_iterator_range ); - template< class S > - void operator[]( S s ) const; - template< class D > - void advance_end( D d ) const; - void back() const; - */ - }; - - template< class Iter > - inline unbounded_iterator_range unbounded_range( Iter r ) - { - return unbounded_iterator_range(r); - } - - namespace detail - { - char is_unbounded_range( ... ); - template< class Iter > - long is_unbounded_range( const unbounded_iterator_range* ); - } - - template< class T > - struct is_unbounded_range - { - private: - static T* ptr_; - - public: - BOOST_STATIC_CONSTANT( bool, - value = sizeof(long) == sizeof(detail::is_unbounded_range(ptr_) ) ); - }; -} - -#endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 965e3cc..e555e7c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -128,6 +128,7 @@ test-suite range : [ range-test counting_range ] [ range-test extension_mechanism ] [ range-test irange ] + [ range-test istream_range ] [ range-test iterator_pair ] [ range-test iterator_range ] # [ range-test mfc : $(VC71_ROOT)/atlmfc/include ] diff --git a/test/istream_range.cpp b/test/istream_range.cpp new file mode 100644 index 0000000..b3e16db --- /dev/null +++ b/test/istream_range.cpp @@ -0,0 +1,51 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// +// For more information, see http://www.boost.org/libs/range/ +// +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ + // Test an integer range with a step size of 1. + void test_istream_range() + { + std::stringstream s; + std::vector reference; + for (int i = 0; i < 10; ++i) + { + reference.push_back(i); + s << i << " "; + } + + std::vector target; + boost::push_back(target, boost::range::istream_range(s)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + target.begin(), target.end() ); + } + +} // namespace anonymous namespace + +boost::unit_test::test_suite* +init_unit_test_suite(int argc, char* argv[]) +{ + boost::unit_test::test_suite* test + = BOOST_TEST_SUITE( "RangeTestSuite.istream_range" ); + + test->add(BOOST_TEST_CASE( &test_istream_range )); + + return test; +}