if (__b < __a) return __b; return __a;
}
+ /**
+ * @brief This does what you think it does.
+ * @param a A thing of arbitrary type.
+ * @param b Another thing of arbitrary type.
+ * @return The greater of the parameters.
+ *
+ * This is the simple classic generic implementation. It will work on
+ * temporary expressions, since they are only evaluated once, unlike a
+ * preprocessor macro.
+ */
template<typename _Tp>
inline const _Tp&
max(const _Tp& __a, const _Tp& __b)
if (__a < __b) return __b; return __a;
}
+ /**
+ * @brief This does what you think it does.
+ * @param a A thing of arbitrary type.
+ * @param b Another thing of arbitrary type.
+ * @param comp A @link s20_3_3_comparisons comparison functor@endlink.
+ * @return The lesser of the parameters.
+ *
+ * This will work on temporary expressions, since they are only evaluated
+ * once, unlike a preprocessor macro.
+ */
template<typename _Tp, typename _Compare>
inline const _Tp&
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
if (__comp(__b, __a)) return __b; return __a;
}
+ /**
+ * @brief This does what you think it does.
+ * @param a A thing of arbitrary type.
+ * @param b Another thing of arbitrary type.
+ * @param comp A @link s20_3_3_comparisons comparison functor@endlink.
+ * @return The greater of the parameters.
+ *
+ * This will work on temporary expressions, since they are only evaluated
+ * once, unlike a preprocessor macro.
+ */
template<typename _Tp, typename _Compare>
inline const _Tp&
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
return __copy_ni2(__first, __last, __result, __Normal());
}
+ /**
+ * @brief Copies the range [first,last) into result.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ * @param result An output iterator.
+ * @return result + (first - last)
+ *
+ * This inline function will boil down to a call to @c memmove whenever
+ * possible. Failing that, if random access iterators are passed, then the
+ * loop count will be known (and therefore a candidate for compiler
+ * optimizations such as unrolling). If the input range and the output
+ * range overlap, then the copy_backward function should be used instead.
+ */
template<typename _InputIter, typename _OutputIter>
inline _OutputIter
copy(_InputIter __first, _InputIter __last, _OutputIter __result)
__Normal());
}
+ /**
+ * @brief Copies the range [first,last) into result.
+ * @param first An input iterator.
+ * @param last An input iterator.
+ * @param result An output iterator.
+ * @return result - (first - last)
+ *
+ * The function has the same effect as copy, but starts at the end of the
+ * range and works its way to the start, returning the start of the result.
+ * This inline function will boil down to a call to @c memmove whenever
+ * possible. Failing that, if random access iterators are passed, then the
+ * loop count will be known (and therefore a candidate for compiler
+ * optimizations such as unrolling).
+ */
template <typename _BI1, typename _BI2>
inline _BI2
copy_backward(_BI1 __first, _BI1 __last, _BI2 __result)
return pair<_RAIter, _OutputIter>(__last, copy(__first, __last, __result));
}
+ /**
+ * @brief Copies the range [first,first+count) into [result,result+count).
+ * @param first An input iterator.
+ * @param count The number of elements to copy.
+ * @param result An output iterator.
+ * @return A std::pair composed of first+count and result+count.
+ *
+ * This is an SGI extension.
+ * This inline function will boil down to a call to @c memmove whenever
+ * possible. Failing that, if random access iterators are passed, then the
+ * loop count will be known (and therefore a candidate for compiler
+ * optimizations such as unrolling).
+ * @ingroup SGIextensions
+ */
template<typename _InputIter, typename _Size, typename _OutputIter>
inline pair<_InputIter, _OutputIter>
copy_n(_InputIter __first, _Size __count, _OutputIter __result)
// fill and fill_n
+ /**
+ * @brief Fills the range [first,last) with copies of value.
+ * @param first A forward iterator.
+ * @param last A forward iterator.
+ * @param value A reference-to-const of arbitrary type.
+ * @return Nothing.
+ *
+ * This function fills a range with copies of the same value. For one-byte
+ * types filling contiguous areas of memory, this becomes an inline call to
+ * @c memset.
+ */
template<typename _ForwardIter, typename _Tp>
void
fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __value)
*__first = __value;
}
+ /**
+ * @brief Fills the range [first,first+n) with copies of value.
+ * @param first An output iterator.
+ * @param n The count of copies to perform.
+ * @param value A reference-to-const of arbitrary type.
+ * @return The iterator at first+n.
+ *
+ * This function fills a range with copies of the same value. For one-byte
+ * types filling contiguous areas of memory, this becomes an inline call to
+ * @c memset.
+ */
template<typename _OutputIter, typename _Size, typename _Tp>
_OutputIter
fill_n(_OutputIter __first, _Size __n, const _Tp& __value)
//--------------------------------------------------
// equal and mismatch
+ /**
+ * @brief Finds the places in ranges which don't match.
+ * @param first1 An input iterator.
+ * @param last1 An input iterator.
+ * @param first2 An input iterator.
+ * @return A pair of iterators pointing to the first mismatch.
+ *
+ * This compares the elements of two ranges using @c == and returns a pair
+ * of iterators. The first iterator points into the first range, the
+ * second iterator points into the second range, and the elements pointed
+ * to by the iterators are not equal.
+ */
template<typename _InputIter1, typename _InputIter2>
pair<_InputIter1, _InputIter2>
mismatch(_InputIter1 __first1, _InputIter1 __last1,
return pair<_InputIter1, _InputIter2>(__first1, __first2);
}
+ /**
+ * @brief Finds the places in ranges which don't match.
+ * @param first1 An input iterator.
+ * @param last1 An input iterator.
+ * @param first2 An input iterator.
+ * @param binary_pred A binary predicate @link s20_3_1_base functor@endlink.
+ * @return A pair of iterators pointing to the first mismatch.
+ *
+ * This compares the elements of two ranges using the binary_pred
+ * parameter, and returns a pair
+ * of iterators. The first iterator points into the first range, the
+ * second iterator points into the second range, and the elements pointed
+ * to by the iterators are not equal.
+ */
template<typename _InputIter1, typename _InputIter2, typename _BinaryPredicate>
pair<_InputIter1, _InputIter2>
mismatch(_InputIter1 __first1, _InputIter1 __last1,
return pair<_InputIter1, _InputIter2>(__first1, __first2);
}
+ /**
+ * @brief Tests a range for element-wise equality.
+ * @param first1 An input iterator.
+ * @param last1 An input iterator.
+ * @param first2 An input iterator.
+ * @return A boolean true or false.
+ *
+ * This compares the elements of two ranges using @c == and returns true or
+ * false depending on whether all of the corresponding elements of the
+ * ranges are equal.
+ */
template<typename _InputIter1, typename _InputIter2>
inline bool
equal(_InputIter1 __first1, _InputIter1 __last1,
return true;
}
+ /**
+ * @brief Tests a range for element-wise equality.
+ * @param first1 An input iterator.
+ * @param last1 An input iterator.
+ * @param first2 An input iterator.
+ * @param binary_pred A binary predicate @link s20_3_1_base functor@endlink.
+ * @return A boolean true or false.
+ *
+ * This compares the elements of two ranges using the binary_pred
+ * parameter, and returns true or
+ * false depending on whether all of the corresponding elements of the
+ * ranges are equal.
+ */
template<typename _InputIter1, typename _InputIter2, typename _BinaryPredicate>
inline bool
equal(_InputIter1 __first1, _InputIter1 __last1,
// lexicographical_compare and lexicographical_compare_3way.
// (the latter is not part of the C++ standard.)
+ /**
+ * @brief Performs "dictionary" comparison on ranges.
+ * @param first1 An input iterator.
+ * @param last1 An input iterator.
+ * @param first2 An input iterator.
+ * @param last2 An input iterator.
+ * @return A boolean true or false.
+ *
+ * "Returns true if the sequence of elements defined by the range
+ * [first1,last1) is lexicographically less than the sequence of elements
+ * defined by the range [first2,last2). Returns false otherwise."
+ * (Quoted from [25.3.8]/1.) If the iterators are all character pointers,
+ * then this is an inline call to @c memcmp.
+ */
template<typename _InputIter1, typename _InputIter2>
bool
lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
return __first1 == __last1 && __first2 != __last2;
}
+ /**
+ * @brief Performs "dictionary" comparison on ranges.
+ * @param first1 An input iterator.
+ * @param last1 An input iterator.
+ * @param first2 An input iterator.
+ * @param last2 An input iterator.
+ * @param comp A @link s20_3_3_comparisons comparison functor@endlink.
+ * @return A boolean true or false.
+ *
+ * The same as the four-parameter @c lexigraphical_compare, but uses the
+ * comp parameter instead of @c <.
+ */
template<typename _InputIter1, typename _InputIter2, typename _Compare>
bool
lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1,
#endif
}
+ /**
+ * @brief @c memcmp on steroids.
+ * @param first1 An input iterator.
+ * @param last1 An input iterator.
+ * @param first2 An input iterator.
+ * @param last2 An input iterator.
+ * @return An int, as with @c memcmp.
+ *
+ * The return value will be less than zero if the first range is
+ * "lexigraphically less than" the second, greater than zero if the second
+ * range is "lexigraphically less than" the first, and zero otherwise.
+ * This is an SGI extension.
+ * @ingroup SGIextensions
+ */
template<typename _InputIter1, typename _InputIter2>
int
lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1,