From 7d246008b6ae46872fe431e767834732c91e5f17 Mon Sep 17 00:00:00 2001 From: Liam Huang Date: Wed, 24 Oct 2018 15:23:44 +0800 Subject: [PATCH] [cpp][15_bsearch] remove hard code for std::less. --- c-cpp/15_bsearch/bsearch.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/c-cpp/15_bsearch/bsearch.hpp b/c-cpp/15_bsearch/bsearch.hpp index 29269ec..a7c64e4 100644 --- a/c-cpp/15_bsearch/bsearch.hpp +++ b/c-cpp/15_bsearch/bsearch.hpp @@ -12,7 +12,7 @@ enum class BsearchPolicy { FIRST, LAST, UNSPECIFIED }; template ::value_type, - typename Compare = std::less> + typename Compare> IterT bsearch(IterT first, IterT last, ValueT target, @@ -50,12 +50,13 @@ IterT bsearch(IterT first, } template ::value_type> + typename ValueT = typename std::iterator_traits::value_type, + typename Compare = std::less> IterT bsearch(IterT first, IterT last, ValueT target, BsearchPolicy policy = BsearchPolicy::UNSPECIFIED) { - return bsearch(first, last, target, std::less(), policy); + return bsearch(first, last, target, Compare(), policy); } #endif // BSEARCH_BSEARCH_HPP_