[cpp][15_bsearch] remove hard code for std::less<T>.

This commit is contained in:
Liam Huang 2018-10-24 15:23:44 +08:00
parent 620ee16882
commit 7d246008b6

View File

@ -12,7 +12,7 @@ enum class BsearchPolicy { FIRST, LAST, UNSPECIFIED };
template <typename IterT, template <typename IterT,
typename ValueT = typename std::iterator_traits<IterT>::value_type, typename ValueT = typename std::iterator_traits<IterT>::value_type,
typename Compare = std::less<ValueT>> typename Compare>
IterT bsearch(IterT first, IterT bsearch(IterT first,
IterT last, IterT last,
ValueT target, ValueT target,
@ -50,12 +50,13 @@ IterT bsearch(IterT first,
} }
template <typename IterT, template <typename IterT,
typename ValueT = typename std::iterator_traits<IterT>::value_type> typename ValueT = typename std::iterator_traits<IterT>::value_type,
typename Compare = std::less<ValueT>>
IterT bsearch(IterT first, IterT bsearch(IterT first,
IterT last, IterT last,
ValueT target, ValueT target,
BsearchPolicy policy = BsearchPolicy::UNSPECIFIED) { BsearchPolicy policy = BsearchPolicy::UNSPECIFIED) {
return bsearch(first, last, target, std::less<ValueT>(), policy); return bsearch(first, last, target, Compare(), policy);
} }
#endif // BSEARCH_BSEARCH_HPP_ #endif // BSEARCH_BSEARCH_HPP_