From 85f019a8e7d33cbba368a6c6b75fd091269e14a1 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 17 Mar 2017 15:14:19 -0700 Subject: Add pdfium::clamp() as a placeholder for std::clamp(). 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 Reviewed-by: Tom Sepez --- third_party/base/stl_util.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'third_party/base') 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 #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 +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_ -- cgit v1.2.3