From 287b2fefe4753e1e03f83b28f3fa318bef26a8fe Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 11 Apr 2019 09:00:36 +0000 Subject: [PATCH] [ADT] Fix template parameter names of llvm::{upper|lower}_bound Summary: Rename template parameter for a search value from 'ForwardIt' to 'T'. While here, also use perfect forwarding to pass the value to STL algos. Reviewers: sammccall Reviewed By: sammccall Subscribers: dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60510 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358158 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/STLExtras.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index abc23b71d51..8a5f6a89336 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -1277,28 +1277,32 @@ auto partition(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range)) { /// Provide wrappers to std::lower_bound which take ranges instead of having to /// pass begin/end explicitly. -template -auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range)) { - return std::lower_bound(adl_begin(Range), adl_end(Range), I); +template +auto lower_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range)) { + return std::lower_bound(adl_begin(Range), adl_end(Range), + std::forward(Value)); } -template -auto lower_bound(R &&Range, ForwardIt I, Compare C) +template +auto lower_bound(R &&Range, T &&Value, Compare C) -> decltype(adl_begin(Range)) { - return std::lower_bound(adl_begin(Range), adl_end(Range), I, C); + return std::lower_bound(adl_begin(Range), adl_end(Range), + std::forward(Value), C); } /// Provide wrappers to std::upper_bound which take ranges instead of having to /// pass begin/end explicitly. -template -auto upper_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range)) { - return std::upper_bound(adl_begin(Range), adl_end(Range), I); +template +auto upper_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range)) { + return std::upper_bound(adl_begin(Range), adl_end(Range), + std::forward(Value)); } -template -auto upper_bound(R &&Range, ForwardIt I, Compare C) +template +auto upper_bound(R &&Range, T &&Value, Compare C) -> decltype(adl_begin(Range)) { - return std::upper_bound(adl_begin(Range), adl_end(Range), I, C); + return std::upper_bound(adl_begin(Range), adl_end(Range), + std::forward(Value), C); } /// Wrapper function around std::equal to detect if all elements /// in a container are same. -- 2.50.1