summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-08-24 12:54:27 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-08-24 12:54:27 +0000
commit0b6962f4be35aca7054ff68ef9bbbb2e03617d31 (patch)
treed43f99c539cadf20ceb01150dee830cbfb2b5d64 /include
parent4321d4e4a9b5786e990a9e731165f3ee3df6fa01 (diff)
downloadllvm-0b6962f4be35aca7054ff68ef9bbbb2e03617d31.tar.gz
llvm-0b6962f4be35aca7054ff68ef9bbbb2e03617d31.tar.bz2
llvm-0b6962f4be35aca7054ff68ef9bbbb2e03617d31.tar.xz
Add a function object to compare the first or second component of a std::pair.
Replace instances of this scattered around the code base. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189169 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/STLExtras.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h
index dacda36521..bfe1392a67 100644
--- a/include/llvm/ADT/STLExtras.h
+++ b/include/llvm/ADT/STLExtras.h
@@ -217,6 +217,22 @@ inline tier<T1, T2> tie(T1& f, T2& s) {
return tier<T1, T2>(f, s);
}
+/// \brief Function object to check whether the first component of a std::pair
+/// compares less than the first component of another std::pair.
+struct less_first {
+ template <typename T> bool operator()(const T &lhs, const T &rhs) const {
+ return lhs.first < rhs.first;
+ }
+};
+
+/// \brief Function object to check whether the second component of a std::pair
+/// compares less than the second component of another std::pair.
+struct less_second {
+ template <typename T> bool operator()(const T &lhs, const T &rhs) const {
+ return lhs.second < rhs.second;
+ }
+};
+
//===----------------------------------------------------------------------===//
// Extra additions for arrays
//===----------------------------------------------------------------------===//