[PATCH] D60510: [ADT] Fix template parameter names of llvm::{upper|lower}_bound
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 10 06:30:46 PDT 2019
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.
Rename template parameter for a search value from 'ForwardIt' to 'T'.
While here, also use perfect forwarding to pass the value to STL algos.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60510
Files:
llvm/include/llvm/ADT/STLExtras.h
Index: llvm/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -1277,28 +1277,32 @@
/// Provide wrappers to std::lower_bound which take ranges instead of having to
/// pass begin/end explicitly.
-template <typename R, typename ForwardIt>
-auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range)) {
- return std::lower_bound(adl_begin(Range), adl_end(Range), I);
+template <typename R, typename T>
+auto lower_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range)) {
+ return std::lower_bound(adl_begin(Range), adl_end(Range),
+ std::forward<T>(Value));
}
-template <typename R, typename ForwardIt, typename Compare>
-auto lower_bound(R &&Range, ForwardIt I, Compare C)
+template <typename R, typename T, typename Compare>
+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<T>(Value), C);
}
/// Provide wrappers to std::upper_bound which take ranges instead of having to
/// pass begin/end explicitly.
-template <typename R, typename ForwardIt>
-auto upper_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range)) {
- return std::upper_bound(adl_begin(Range), adl_end(Range), I);
+template <typename R, typename T>
+auto upper_bound(R &&Range, T && Value) -> decltype(adl_begin(Range)) {
+ return std::upper_bound(adl_begin(Range), adl_end(Range),
+ std::forward<T>(Value));
}
-template <typename R, typename ForwardIt, typename Compare>
-auto upper_bound(R &&Range, ForwardIt I, Compare C)
+template <typename R, typename T, typename Compare>
+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<T>(Value), C);
}
/// Wrapper function around std::equal to detect if all elements
/// in a container are same.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60510.194502.patch
Type: text/x-patch
Size: 2235 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190410/b820ad67/attachment.bin>
More information about the cfe-commits
mailing list