Boost.Range updated the return types of various algorithms to improve consistency. This is to address a specific request made during the formal review of Boost.RangeEx.

[SVN r61211]
This commit is contained in:
Neil Groves
2010-04-11 22:05:02 +00:00
parent cab01e8ba3
commit 350a1f8bfc
108 changed files with 937 additions and 605 deletions

View File

@ -26,6 +26,7 @@ namespace boost
/// range-based version of the fill_n std algorithm
///
/// \pre ForwardRange is a model of the ForwardRangeConcept
/// \pre n <= std::distance(boost::begin(rng), boost::end(rng))
template< class ForwardRange, class Size, class Value >
inline ForwardRange& fill_n(ForwardRange& rng, Size n, const Value& val)
{

View File

@ -35,26 +35,29 @@ inline void push_heap(RandomAccessRange& rng)
/// \overload
template<class RandomAccessRange>
inline void push_heap(const RandomAccessRange& rng)
inline const RandomAccessRange& push_heap(const RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::push_heap(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void push_heap(RandomAccessRange& rng, Compare comp_pred)
inline RandomAccessRange& push_heap(RandomAccessRange& rng, Compare comp_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::push_heap(boost::begin(rng), boost::end(rng), comp_pred);
return rng;
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void push_heap(const RandomAccessRange& rng, Compare comp_pred)
inline const RandomAccessRange& push_heap(const RandomAccessRange& rng, Compare comp_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::push_heap(boost::begin(rng), boost::end(rng), comp_pred);
return rng;
}
/// \brief template function pop_heap
@ -64,34 +67,38 @@ inline void push_heap(const RandomAccessRange& rng, Compare comp_pred)
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void pop_heap(RandomAccessRange& rng)
inline RandomAccessRange& pop_heap(RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::pop_heap(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange>
inline void pop_heap(const RandomAccessRange& rng)
inline const RandomAccessRange& pop_heap(const RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::pop_heap(boost::begin(rng),boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void pop_heap(RandomAccessRange& rng, Compare comp_pred)
inline RandomAccessRange& pop_heap(RandomAccessRange& rng, Compare comp_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred);
return rng;
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void pop_heap(const RandomAccessRange& rng, Compare comp_pred)
inline const RandomAccessRange& pop_heap(const RandomAccessRange& rng, Compare comp_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred);
return rng;
}
/// \brief template function make_heap
@ -101,34 +108,38 @@ inline void pop_heap(const RandomAccessRange& rng, Compare comp_pred)
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void make_heap(RandomAccessRange& rng)
inline RandomAccessRange& make_heap(RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::make_heap(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange>
inline void make_heap(const RandomAccessRange& rng)
inline RandomAccessRange& make_heap(const RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::make_heap(boost::begin(rng),boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void make_heap(RandomAccessRange& rng, Compare comp_pred)
inline RandomAccessRange& make_heap(RandomAccessRange& rng, Compare comp_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::make_heap(boost::begin(rng), boost::end(rng), comp_pred);
return rng;
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void make_heap(const RandomAccessRange& rng, Compare comp_pred)
inline const RandomAccessRange& make_heap(const RandomAccessRange& rng, Compare comp_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::make_heap(boost::begin(rng), boost::end(rng), comp_pred);
return rng;
}
/// \brief template function sort_heap
@ -138,34 +149,38 @@ inline void make_heap(const RandomAccessRange& rng, Compare comp_pred)
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre Compare is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void sort_heap(RandomAccessRange& rng)
inline RandomAccessRange& sort_heap(RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::sort_heap(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange>
inline void sort_heap(const RandomAccessRange& rng)
inline const RandomAccessRange& sort_heap(const RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::sort_heap(boost::begin(rng), boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void sort_heap(RandomAccessRange& rng, Compare comp_pred)
inline RandomAccessRange& sort_heap(RandomAccessRange& rng, Compare comp_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred);
return rng;
}
/// \overload
template<class RandomAccessRange, class Compare>
inline void sort_heap(const RandomAccessRange& rng, Compare comp_pred)
inline const RandomAccessRange& sort_heap(const RandomAccessRange& rng, Compare comp_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred);
return rng;
}
} // namespace range

View File

@ -27,40 +27,44 @@ namespace boost
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void nth_element(RandomAccessRange& rng,
inline RandomAccessRange& nth_element(RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type nth)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::nth_element(boost::begin(rng), nth, boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange>
inline void nth_element(const RandomAccessRange& rng,
inline const RandomAccessRange& nth_element(const RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type nth)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::nth_element(boost::begin(rng),nth,boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline void nth_element(RandomAccessRange& rng,
inline RandomAccessRange& nth_element(RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type nth,
BinaryPredicate sort_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::nth_element(boost::begin(rng), nth, boost::end(rng), sort_pred);
return rng;
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline void nth_element(const RandomAccessRange& rng,
inline const RandomAccessRange& nth_element(const RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type nth,
BinaryPredicate sort_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::nth_element(boost::begin(rng),nth,boost::end(rng), sort_pred);
return rng;
}
} // namespace range

View File

@ -27,41 +27,45 @@ namespace boost
/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template<class RandomAccessRange>
inline void partial_sort(RandomAccessRange& rng,
inline RandomAccessRange& partial_sort(RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::partial_sort(boost::begin(rng), middle, boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange>
inline void partial_sort(const RandomAccessRange& rng,
inline const RandomAccessRange& partial_sort(const RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::partial_sort(boost::begin(rng), middle, boost::end(rng));
return rng;
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline void partial_sort(RandomAccessRange& rng,
inline RandomAccessRange& partial_sort(RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle,
BinaryPredicate sort_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
std::partial_sort(boost::begin(rng), middle, boost::end(rng),
sort_pred);
return rng;
}
/// \overload
template<class RandomAccessRange, class BinaryPredicate>
inline void partial_sort(const RandomAccessRange& rng,
inline const RandomAccessRange& partial_sort(const RandomAccessRange& rng,
BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle,
BinaryPredicate sort_pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::partial_sort(boost::begin(rng), middle, boost::end(rng), sort_pred);
return rng;
}
} // namespace range

View File

@ -24,29 +24,32 @@ namespace boost
{
template< class Container >
inline void erase( Container& on,
inline Container& erase( Container& on,
iterator_range<BOOST_DEDUCED_TYPENAME Container::iterator> to_erase )
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
on.erase( boost::begin(to_erase), boost::end(to_erase) );
return on;
}
template< class Container, class T >
inline void remove_erase( Container& on, const T& val )
inline Container& remove_erase( Container& on, const T& val )
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
on.erase(
std::remove(boost::begin(on), boost::end(on), val),
boost::end(on));
return on;
}
template< class Container, class Pred >
inline void remove_erase_if( Container& on, Pred pred )
inline Container& remove_erase_if( Container& on, Pred pred )
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
on.erase(
std::remove_if(boost::begin(on), boost::end(on), pred),
boost::end(on));
return on;
}
} // namespace range

View File

@ -23,15 +23,16 @@ namespace boost
{
template< class Container, class Range >
inline void insert( Container& on,
BOOST_DEDUCED_TYPENAME Container::iterator before,
const Range& from )
inline Container& insert( Container& on,
BOOST_DEDUCED_TYPENAME Container::iterator before,
const Range& from )
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
BOOST_ASSERT( (void*)&on != (void*)&from &&
"cannot copy from a container to itself" );
on.insert( before, boost::begin(from), boost::end(from) );
return on;
}
} // namespace range

View File

@ -22,7 +22,7 @@ namespace boost
{
template< class ForwardRange, class Value >
inline void iota( ForwardRange& rng, Value x )
inline ForwardRange& iota( ForwardRange& rng, Value x )
{
BOOST_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator_t;
@ -30,6 +30,8 @@ inline void iota( ForwardRange& rng, Value x )
iterator_t last_target = ::boost::end(rng);
for (iterator_t target = ::boost::begin(rng); target != last_target; ++target, ++x)
*target = x;
return rng;
}
} // namespace range

View File

@ -23,13 +23,14 @@ namespace boost
{
template< class Container, class Range >
inline void push_back( Container& on, const Range& from )
inline Container& push_back( Container& on, const Range& from )
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
BOOST_ASSERT( (void*)&on != (void*)&from &&
"cannot copy from a container to itself" );
on.insert( on.end(), boost::begin(from), boost::end(from) );
return on;
}
} // namespace range

View File

@ -23,13 +23,14 @@ namespace boost
{
template< class Container, class Range >
inline void push_front( Container& on, const Range& from )
inline Container& push_front( Container& on, const Range& from )
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
BOOST_ASSERT( (void*)&on != (void*)&from &&
"cannot copy from a container to itself" );
on.insert( on.begin(), boost::begin(from), boost::end(from) );
return on;
}
} // namespace range