Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkTPin.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkTPin_DEFINED
9#define SkTPin_DEFINED
10
11#include <algorithm>
12
13/** @return x pinned (clamped) between lo and hi, inclusively.
14
15 Unlike std::clamp(), SkTPin() always returns a value between lo and hi.
16 If x is NaN, SkTPin() returns lo but std::clamp() returns NaN.
17*/
18template <typename T>
19static constexpr const T& SkTPin(const T& x, const T& lo, const T& hi) {
20 return std::max(lo, std::min(x, hi));
21}
22
23#endif
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
Definition SkTPin.h:19
double x
#define T