diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-08-24 12:54:27 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-08-24 12:54:27 +0000 |
commit | 0b6962f4be35aca7054ff68ef9bbbb2e03617d31 (patch) | |
tree | d43f99c539cadf20ceb01150dee830cbfb2b5d64 /include/llvm/ADT | |
parent | 4321d4e4a9b5786e990a9e731165f3ee3df6fa01 (diff) | |
download | external_llvm-0b6962f4be35aca7054ff68ef9bbbb2e03617d31.zip external_llvm-0b6962f4be35aca7054ff68ef9bbbb2e03617d31.tar.gz external_llvm-0b6962f4be35aca7054ff68ef9bbbb2e03617d31.tar.bz2 |
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/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/STLExtras.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index dacda36..bfe1392 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 //===----------------------------------------------------------------------===// |