Lines Matching refs:value

56   static constexpr bool Do(Src value) {
67 std::is_integral<Dst>::value && std::is_integral<Src>::value &&
68 std::is_signed<Dst>::value && std::is_signed<Src>::value &&
69 !IsTypeInRangeForNumericType<Dst, Src>::value>::type> {
72 static constexpr bool Do(Src value) {
74 // type, and then see if it matches the original value.
75 return value == static_cast<Dst>(value);
84 std::is_integral<Dst>::value && std::is_integral<Src>::value &&
85 !std::is_signed<Dst>::value && std::is_signed<Src>::value &&
86 !IsTypeInRangeForNumericType<Dst, Src>::value>::type> {
89 static constexpr bool Do(Src value) {
92 return as_unsigned(value) <= as_unsigned(CommonMax<Src, Dst>());
96 // Convenience function that returns true if the supplied value is in range
99 constexpr bool IsValueInRangeForNumericType(Src value) {
103 static_cast<SrcType>(value))
105 static_cast<SrcType>(value))
114 constexpr Dst checked_cast(Src value) {
118 return BASE_NUMERICS_LIKELY((IsValueInRangeForNumericType<Dst>(value)))
119 ? static_cast<Dst>(static_cast<SrcType>(value))
148 constexpr Dst saturated_cast_impl(Src value, RangeCheck constraint) {
152 ? (!constraint.IsUnderflowFlagSet() ? static_cast<Dst>(value)
155 : (std::is_integral<Src>::value || !constraint.IsUnderflowFlagSet()
166 static constexpr Dst Do(Src value) {
175 typename std::enable_if<std::is_integral<Src>::value &&
176 std::is_integral<Dst>::value &&
179 static constexpr Dst Do(Src value) {
180 return SaturateFastAsmOp<Dst, Src>::Do(value);
187 typename std::enable_if<std::is_integral<Src>::value &&
188 std::is_integral<Dst>::value &&
191 static constexpr Dst Do(Src value) {
197 (!IsMinInRangeForNumericType<Dst, Src>() && IsValueNegative(value)));
198 return BASE_NUMERICS_LIKELY(IsValueInRangeForNumericType<Dst>(value))
199 ? static_cast<Dst>(value)
211 constexpr Dst saturated_cast(Src value) {
213 return !IsCompileTimeConstant(value) &&
216 SaturationDefaultLimits<Dst>>::value
217 ? SaturateFastOp<Dst, SrcType>::Do(static_cast<SrcType>(value))
219 static_cast<SrcType>(value),
221 static_cast<SrcType>(value)));
226 // to contain any value in the source type. It performs no runtime checking.
228 constexpr Dst strict_cast(Src value) {
231 static_assert(std::is_arithmetic<Dst>::value, "Result must be numeric.");
239 static_assert(StaticDstRangeRelationToSrcRange<Dst, SrcType>::value ==
244 return static_cast<Dst>(static_cast<SrcType>(value));
250 static constexpr bool value = false;
256 typename std::enable_if<ArithmeticOrUnderlyingEnum<Dst>::value &&
257 ArithmeticOrUnderlyingEnum<Src>::value>::type> {
258 static constexpr bool value =
259 StaticDstRangeRelationToSrcRange<Dst, Src>::value ==
272 // CheckedNumeric for runtime range checks of the actual value being assigned.
288 constexpr StrictNumeric(Src value) // NOLINT(runtime/explicit)
289 : value_(strict_cast<T>(value)) {}
297 // the member value functions (e.g. val.template ValueOrDie<Dst>()), use one
298 // of the value helper functions (e.g. ValueOrDieForType<Dst>(val)).
304 Dst, T>::value>::type* = nullptr>
316 const T value) {
317 return value;
323 std::ostream& operator<<(std::ostream& os, const StrictNumeric<T>& value) {
324 os << static_cast<T>(value);
332 internal::Is##CLASS##Op<L, R>::value>::type* = nullptr> \
366 typename = std::enable_if_t<std::is_integral<Dst>::value &&
367 std::is_floating_point<Src>::value>>
368 Dst ClampFloor(Src value) {
369 return saturated_cast<Dst>(std::floor(value));
372 typename = std::enable_if_t<std::is_integral<Dst>::value &&
373 std::is_floating_point<Src>::value>>
374 Dst ClampCeil(Src value) {
375 return saturated_cast<Dst>(std::ceil(value));
378 typename = std::enable_if_t<std::is_integral<Dst>::value &&
379 std::is_floating_point<Src>::value>>
380 Dst ClampRound(Src value) {
382 (value >= 0.0f) ? std::floor(value + 0.5f) : std::ceil(value - 0.5f);