[boost][range] - Resolved Trace 5162 - boost::iterator_range<T*> is unsafe.

[SVN r70852]
This commit is contained in:
Neil Groves
2011-04-02 13:05:26 +00:00
parent d490a84c8d
commit 126e6861d7
4 changed files with 33 additions and 2 deletions

View File

@ -53,13 +53,13 @@ namespace boost
template< class ForwardRange >
static IteratorT adl_begin( ForwardRange& r )
{
return IteratorT( boost::begin( r ) );
return static_cast<IteratorT>( boost::begin( r ) );
}
template< class ForwardRange >
static IteratorT adl_end( ForwardRange& r )
{
return IteratorT( boost::end( r ) );
return static_cast<IteratorT>( boost::end( r ) );
}
};

View File

@ -31,6 +31,7 @@ rule range-test ( name : includes * )
}
test-suite range :
[ compile-fail compile_fail/iterator_range1.cpp ]
[ range-test adaptor_test/adjacent_filtered ]
[ range-test adaptor_test/copied ]
[ range-test adaptor_test/filtered ]

View File

@ -0,0 +1,21 @@
// Boost.Range library
//
// Copyright Neil Groves 2011. 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 <boost/range/iterator_range_core.hpp>
namespace iterator_range_test_detail
{
void check_iterator_range_doesnt_convert_pointers()
{
double source[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
boost::iterator_range<float*> rng = boost::make_iterator_range(source);
}
}

View File

@ -200,6 +200,15 @@ namespace iterator_range_test_detail
}
}
}
void check_iterator_range_from_array()
{
double source[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
boost::iterator_range<double*> rng = boost::make_iterator_range(source);
BOOST_CHECK_EQUAL_COLLECTIONS( rng.begin(), rng.end(),
source, source + 6 );
}
} // namespace iterator_range_test_detail
template<typename Pred>