Lines Matching refs:Dst
40 template <typename Dst, typename Src>
43 static constexpr Dst Do(Src) { in Do()
45 return CheckOnFailure::template HandleFailure<Dst>(); in Do()
53 template <typename Dst, typename Src, typename Enable = void>
63 template <typename Dst, typename Src>
65 Dst, Src,
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> {
75 return value == static_cast<Dst>(value);
80 template <typename Dst, typename Src>
82 Dst, Src,
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> {
92 return as_unsigned(value) <= as_unsigned(CommonMax<Src, Dst>());
98 template <typename Dst, typename Src>
101 return internal::IsValueInRangeFastOp<Dst, SrcType>::is_supported
102 ? internal::IsValueInRangeFastOp<Dst, SrcType>::Do(
104 : internal::DstRangeRelationToSrcRange<Dst>(
112 template <typename Dst, class CheckHandler = internal::CheckOnFailure,
114 constexpr Dst checked_cast(Src value) {
118 return BASE_NUMERICS_LIKELY((IsValueInRangeForNumericType<Dst>(value)))
119 ? static_cast<Dst>(static_cast<SrcType>(value))
120 : CheckHandler::template HandleFailure<Dst>();
147 template <typename Dst, template <typename> class S, typename Src>
148 constexpr Dst saturated_cast_impl(Src value, RangeCheck constraint) {
152 ? (!constraint.IsUnderflowFlagSet() ? static_cast<Dst>(value)
153 : S<Dst>::Underflow())
156 ? S<Dst>::Overflow()
157 : S<Dst>::NaN());
163 template <typename Dst, typename Src, typename Enable = void>
166 static constexpr Dst Do(Src value) {
168 return CheckOnFailure::template HandleFailure<Dst>();
172 template <typename Dst, typename Src>
174 Dst, Src,
176 std::is_integral<Dst>::value &&
177 SaturateFastAsmOp<Dst, Src>::is_supported>::type> {
179 static constexpr Dst Do(Src value) {
180 return SaturateFastAsmOp<Dst, Src>::Do(value);
184 template <typename Dst, typename Src>
186 Dst, Src,
188 std::is_integral<Dst>::value &&
189 !SaturateFastAsmOp<Dst, Src>::is_supported>::type> {
191 static constexpr Dst Do(Src value) {
195 const Dst saturated = CommonMaxOrMin<Dst, Src>(
196 IsMaxInRangeForNumericType<Dst, Src>() ||
197 (!IsMinInRangeForNumericType<Dst, Src>() && IsValueNegative(value)));
198 return BASE_NUMERICS_LIKELY(IsValueInRangeForNumericType<Dst>(value))
199 ? static_cast<Dst>(value)
208 template <typename Dst,
211 constexpr Dst saturated_cast(Src value) {
214 SaturateFastOp<Dst, SrcType>::is_supported &&
215 std::is_same<SaturationHandler<Dst>,
216 SaturationDefaultLimits<Dst>>::value
217 ? SaturateFastOp<Dst, SrcType>::Do(static_cast<SrcType>(value))
218 : saturated_cast_impl<Dst, SaturationHandler, SrcType>(
220 DstRangeRelationToSrcRange<Dst, SaturationHandler, SrcType>(
227 template <typename Dst, typename Src>
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));
248 template <typename Dst, typename Src, class Enable = void>
253 template <typename Dst, typename Src>
255 Dst, Src,
256 typename std::enable_if<ArithmeticOrUnderlyingEnum<Dst>::value &&
259 StaticDstRangeRelationToSrcRange<Dst, Src>::value ==
303 template <typename Dst, typename std::enable_if<IsNumericRangeContained<
304 Dst, T>::value>::type* = nullptr>
305 constexpr operator Dst() const {
306 return static_cast<typename ArithmeticOrUnderlyingEnum<Dst>::type>(value_);
365 template <typename Dst = int, typename Src,
366 typename = std::enable_if_t<std::is_integral<Dst>::value &&
368 Dst ClampFloor(Src value) {
369 return saturated_cast<Dst>(std::floor(value));
371 template <typename Dst = int, typename Src,
372 typename = std::enable_if_t<std::is_integral<Dst>::value &&
374 Dst ClampCeil(Src value) {
375 return saturated_cast<Dst>(std::ceil(value));
377 template <typename Dst = int, typename Src,
378 typename = std::enable_if_t<std::is_integral<Dst>::value &&
380 Dst ClampRound(Src value) {
383 return saturated_cast<Dst>(rounded);