llvm.org GIT mirror llvm / 287b2fe
[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 Ilya Biryukov 1 year, 5 months ago
1 changed file(s) with 20 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
12761276
12771277 /// Provide wrappers to std::lower_bound which take ranges instead of having to
12781278 /// pass begin/end explicitly.
1279 template
1280 auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range)) {
1281 return std::lower_bound(adl_begin(Range), adl_end(Range), I);
1282 }
1283
1284 template
1285 auto lower_bound(R &&Range, ForwardIt I, Compare C)
1279 template
1280 auto lower_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range)) {
1281 return std::lower_bound(adl_begin(Range), adl_end(Range),
1282 std::forward(Value));
1283 }
1284
1285 template
1286 auto lower_bound(R &&Range, T &&Value, Compare C)
12861287 -> decltype(adl_begin(Range)) {
1287 return std::lower_bound(adl_begin(Range), adl_end(Range), I, C);
1288 return std::lower_bound(adl_begin(Range), adl_end(Range),
1289 std::forward(Value), C);
12881290 }
12891291
12901292 /// Provide wrappers to std::upper_bound which take ranges instead of having to
12911293 /// pass begin/end explicitly.
1292 template
1293 auto upper_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range)) {
1294 return std::upper_bound(adl_begin(Range), adl_end(Range), I);
1295 }
1296
1297 template
1298 auto upper_bound(R &&Range, ForwardIt I, Compare C)
1294 template
1295 auto upper_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range)) {
1296 return std::upper_bound(adl_begin(Range), adl_end(Range),
1297 std::forward(Value));
1298 }
1299
1300 template
1301 auto upper_bound(R &&Range, T &&Value, Compare C)
12991302 -> decltype(adl_begin(Range)) {
1300 return std::upper_bound(adl_begin(Range), adl_end(Range), I, C);
1303 return std::upper_bound(adl_begin(Range), adl_end(Range),
1304 std::forward(Value), C);
13011305 }
13021306 /// Wrapper function around std::equal to detect if all elements
13031307 /// in a container are same.