|
Squid Web Cache master
|
Go to the source code of this file.
Namespaces | |
| namespace | Math |
Typedefs | |
| template<typename T , typename U > | |
| using | AllUnsigned = typename std::conditional< std::is_unsigned< T >::value &&std::is_unsigned< U >::value, std::true_type, std::false_type >::type |
Functions | |
| int | Math::intPercent (const int a, const int b) |
| int64_t | Math::int64Percent (const int64_t a, const int64_t b) |
| double | Math::doublePercent (const double, const double) |
| int | Math::intAverage (const int, const int, int, const int) |
| double | Math::doubleAverage (const double, const double, int, const int) |
| template<typename A , typename B > | |
| constexpr bool | Less (const A a, const B b) |
| whether integer a is less than integer b, with correct overflow handling | |
| template<typename T > | |
| constexpr void | AssertNaturalType () |
| ensure that T is supported by NaturalSum() and friends | |
| template<typename S , typename A , typename B , std::enable_if_t< AllUnsigned< A, B >::value, int > = 0> | |
| std::optional< S > | IncreaseSumInternal (const A a, const B b) |
| template<typename S , typename A , typename B , std::enable_if_t<!AllUnsigned< A, B >::value, int > = 0> | |
| std::optional< S > constexpr | IncreaseSumInternal (const A a, const B b) |
| template<typename S , typename T > | |
| std::optional< S > | IncreaseSum (const S s, const T t) |
| argument pack expansion termination for IncreaseSum<S, T, Args...>() | |
| template<typename S , typename T , typename... Args> | |
| std::optional< S > | IncreaseSum (const S sum, const T t, const Args... args) |
| template<typename SummationType , typename... Args> | |
| std::optional< SummationType > | NaturalSum (const Args... args) |
| template<typename S , typename... Args> | |
| S | SetToNaturalSumOrMax (S &var, const Args... args) |
| template<typename Result , typename Source > | |
| Result | NaturalCast (const Source s) |
| using AllUnsigned = typename std::conditional< std::is_unsigned<T>::value && std::is_unsigned<U>::value, std::true_type, std::false_type >::type |
detects a pair of unsigned types reduces code duplication in declarations further below
Definition at line 38 of file SquidMath.h.
|
constexpr |
Definition at line 62 of file SquidMath.h.
| std::optional< S > IncreaseSum | ( | const S | s, |
| const T | t | ||
| ) |
Definition at line 144 of file SquidMath.h.
Referenced by Store::ParsingBuffer::appended(), Store::ParsingBuffer::growSpace(), and IncreaseSum().
| std::optional< S > IncreaseSum | ( | const S | sum, |
| const T | t, | ||
| const Args... | args | ||
| ) |
Definition at line 155 of file SquidMath.h.
References head, and IncreaseSum().
| std::optional< S > IncreaseSumInternal | ( | const A | a, |
| const B | b | ||
| ) |
This IncreaseSumInternal() overload is optimized for speed.
Definition at line 76 of file SquidMath.h.
|
constexpr |
This IncreaseSumInternal() overload supports a larger variety of types.
Definition at line 112 of file SquidMath.h.
References Less().
|
constexpr |
Definition at line 48 of file SquidMath.h.
Referenced by Store::SwapMetaUnpacker::SwapMetaUnpacker(), ccNameByType(), IncreaseSumInternal(), AnyP::Uri::parsePort(), HttpReply::parseTerminatedPrefix(), peer_Inst(), clientReplyContext::processReplyAccessResult(), store_client::readBody(), store_client::skipHttpHeadersFromDisk(), and Store::UnpackPrefix().
| Result NaturalCast | ( | const Source | s | ) |
converts a given non-negative integer into an integer of a given type without loss of information or undefined behavior
Definition at line 186 of file SquidMath.h.
| std::optional< SummationType > NaturalSum | ( | const Args... | args | ) |
Definition at line 167 of file SquidMath.h.
| S SetToNaturalSumOrMax | ( | S & | var, |
| const Args... | args | ||
| ) |
Safely resets the given variable to NaturalSum() of the given arguments. If the sum overflows, resets to variable's maximum possible value.
Definition at line 176 of file SquidMath.h.
Referenced by ClpMap< Key, Value, MemoryUsedBy >::Entry::Entry(), and TestMath::testNaturalSum().