mirror of
https://github.com/boostorg/range.git
synced 2025-07-18 07:02:25 +02:00
*** empty log message ***
[SVN r32015]
This commit is contained in:
@ -143,6 +143,14 @@ namespace boost
|
|||||||
//! This type
|
//! This type
|
||||||
typedef iterator_range<IteratorT> this_type;
|
typedef iterator_range<IteratorT> this_type;
|
||||||
|
|
||||||
|
//! Refence type
|
||||||
|
//
|
||||||
|
// Needed because value-type is the same for
|
||||||
|
// const and non-const iterators
|
||||||
|
//
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME
|
||||||
|
iterator_reference<IteratorT>::type reference;
|
||||||
|
|
||||||
//! const_iterator type
|
//! const_iterator type
|
||||||
/*!
|
/*!
|
||||||
There is no distinction between const_iterator and iterator.
|
There is no distinction between const_iterator and iterator.
|
||||||
@ -306,20 +314,20 @@ namespace boost
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public: // convenience
|
public: // convenience
|
||||||
value_type& front() const
|
reference front() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( !empty() );
|
BOOST_ASSERT( !empty() );
|
||||||
return *m_Begin;
|
return *m_Begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type& back() const
|
reference back() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( !empty() );
|
BOOST_ASSERT( !empty() );
|
||||||
IteratorT last( m_End );
|
IteratorT last( m_End );
|
||||||
return *--last;
|
return *--last;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type& operator[]( size_type sz ) const
|
reference operator[]( size_type sz ) const
|
||||||
{
|
{
|
||||||
//BOOST_STATIC_ASSERT( is_random_access );
|
//BOOST_STATIC_ASSERT( is_random_access );
|
||||||
BOOST_ASSERT( sz < size() );
|
BOOST_ASSERT( sz < size() );
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Boost.Range library
|
// Boost.Range library
|
||||||
//
|
//
|
||||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
// Copyright Thorsten Ottosen & Larry Evans 2003-2005. Use, modification and
|
||||||
// distribution is subject to the Boost Software License, Version
|
// distribution is subject to the Boost Software License, Version
|
||||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@ -27,6 +27,8 @@
|
|||||||
using namespace boost;
|
using namespace boost;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
void check_reference_type();
|
||||||
|
|
||||||
void check_iterator_range()
|
void check_iterator_range()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -91,6 +93,8 @@ void check_iterator_range()
|
|||||||
BOOST_CHECK( rrr == "ello worl" );
|
BOOST_CHECK( rrr == "ello worl" );
|
||||||
rrr = make_iterator_range( rrr, -1, 1 );
|
rrr = make_iterator_range( rrr, -1, 1 );
|
||||||
BOOST_CHECK( rrr == str );
|
BOOST_CHECK( rrr == str );
|
||||||
|
|
||||||
|
check_reference_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,3 +109,33 @@ test_suite* init_unit_test_suite( int argc, char* argv[] )
|
|||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Check that constness is propgated correct from
|
||||||
|
// the iterator types.
|
||||||
|
//
|
||||||
|
// Test contributed by Larry Evans.
|
||||||
|
//
|
||||||
|
|
||||||
|
template< class Container >
|
||||||
|
void test_iter_range( Container& a_cont )
|
||||||
|
{
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME range_result_iterator<Container>::type citer_type;
|
||||||
|
typedef iterator_range<citer_type> riter_type;
|
||||||
|
riter_type a_riter( make_iterator_range( a_cont ) );
|
||||||
|
a_riter.front();
|
||||||
|
a_riter.back();
|
||||||
|
int i = a_riter[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void check_reference_type()
|
||||||
|
{
|
||||||
|
typedef vector<int> veci_type;
|
||||||
|
veci_type a_vec;
|
||||||
|
a_vec.push_back( 999 );
|
||||||
|
test_iter_range<veci_type>(a_vec);
|
||||||
|
test_iter_range<veci_type const>(a_vec);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user