summaryrefslogtreecommitdiff
path: root/third_party/base/stl_util.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-03-17 15:14:19 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-17 22:54:26 +0000
commit85f019a8e7d33cbba368a6c6b75fd091269e14a1 (patch)
tree8dcf6fcd98309a48ebbd9e46cc8c0d23a57c0965 /third_party/base/stl_util.h
parent240fe6d79f234896a966ddce0b9a125776dc9171 (diff)
downloadpdfium-85f019a8e7d33cbba368a6c6b75fd091269e14a1.tar.xz
Add pdfium::clamp() as a placeholder for std::clamp().chromium/3046
Ue it to fix a typo as well. BUG=pdfium:634 Change-Id: I2d686242ffb841aedc2fae6a3cf7a00bea667404 Reviewed-on: https://pdfium-review.googlesource.com/3113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'third_party/base/stl_util.h')
-rw-r--r--third_party/base/stl_util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/third_party/base/stl_util.h b/third_party/base/stl_util.h
index 96947f5e53..9c71530c12 100644
--- a/third_party/base/stl_util.h
+++ b/third_party/base/stl_util.h
@@ -10,6 +10,7 @@
#include <set>
#include "third_party/base/numerics/safe_conversions.h"
+#include "third_party/base/stl_util.h"
namespace pdfium {
@@ -67,6 +68,12 @@ class ScopedSetInsertion {
const T m_Entry;
};
+// std::clamp(), some day.
+template <class T>
+constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
+ return std::min(std::max(v, lo), hi);
+}
+
} // namespace pdfium
#endif // PDFIUM_THIRD_PARTY_BASE_STL_UTIL_H_