Lines Matching refs:Dst

27 template <typename Dst, typename Src>
30 static constexpr Dst Do(Src) { in Do()
32 return CheckOnFailure::template HandleFailure<Dst>(); in Do()
40 template <typename Dst, typename Src, typename Enable = void>
50 template <typename Dst, typename Src>
52 Dst,
55 std::is_integral<Dst>::value && std::is_integral<Src>::value &&
56 std::is_signed<Dst>::value && std::is_signed<Src>::value &&
57 !IsTypeInRangeForNumericType<Dst, Src>::value>::type> {
63 return value == static_cast<Dst>(value);
68 template <typename Dst, typename Src>
70 Dst,
73 std::is_integral<Dst>::value && std::is_integral<Src>::value &&
74 !std::is_signed<Dst>::value && std::is_signed<Src>::value &&
75 !IsTypeInRangeForNumericType<Dst, Src>::value>::type> {
81 return as_unsigned(value) <= as_unsigned(CommonMax<Src, Dst>());
87 template <typename Dst, typename Src>
90 return internal::IsValueInRangeFastOp<Dst, SrcType>::is_supported
91 ? internal::IsValueInRangeFastOp<Dst, SrcType>::Do(
93 : internal::DstRangeRelationToSrcRange<Dst>(
101 template <typename Dst,
104 constexpr Dst checked_cast(Src value) {
108 return BASE_NUMERICS_LIKELY((IsValueInRangeForNumericType<Dst>(value)))
109 ? static_cast<Dst>(static_cast<SrcType>(value))
110 : CheckHandler::template HandleFailure<Dst>();
137 template <typename Dst, template <typename> class S, typename Src>
138 constexpr Dst saturated_cast_impl(Src value, RangeCheck constraint) {
142 ? (!constraint.IsUnderflowFlagSet() ? static_cast<Dst>(value)
143 : S<Dst>::Underflow())
146 ? S<Dst>::Overflow()
147 : S<Dst>::NaN());
153 template <typename Dst, typename Src, typename Enable = void>
156 static constexpr Dst Do(Src value) {
158 return CheckOnFailure::template HandleFailure<Dst>();
162 template <typename Dst, typename Src>
164 Dst,
167 std::is_integral<Dst>::value>::type> {
169 static Dst Do(Src value) {
170 if (SaturateFastAsmOp<Dst, Src>::is_supported)
171 return SaturateFastAsmOp<Dst, Src>::Do(value);
176 Dst saturated = CommonMaxOrMin<Dst, Src>(
177 IsMaxInRangeForNumericType<Dst, Src>() ||
178 (!IsMinInRangeForNumericType<Dst, Src>() && IsValueNegative(value)));
179 return BASE_NUMERICS_LIKELY(IsValueInRangeForNumericType<Dst>(value))
180 ? static_cast<Dst>(value)
189 template <typename Dst,
192 constexpr Dst saturated_cast(Src value) {
195 SaturateFastOp<Dst, SrcType>::is_supported &&
196 std::is_same<SaturationHandler<Dst>,
197 SaturationDefaultLimits<Dst>>::value
198 ? SaturateFastOp<Dst, SrcType>::Do(static_cast<SrcType>(value))
199 : saturated_cast_impl<Dst, SaturationHandler, SrcType>(
201 DstRangeRelationToSrcRange<Dst, SaturationHandler, SrcType>(
208 template <typename Dst, typename Src>
209 constexpr Dst strict_cast(Src value) {
212 static_assert(std::is_arithmetic<Dst>::value, "Result must be numeric.");
220 static_assert(StaticDstRangeRelationToSrcRange<Dst, SrcType>::value ==
225 return static_cast<Dst>(static_cast<SrcType>(value));
229 template <typename Dst, typename Src, class Enable = void>
234 template <typename Dst, typename Src>
236 Dst,
238 typename std::enable_if<ArithmeticOrUnderlyingEnum<Dst>::value &&
240 static const bool value = StaticDstRangeRelationToSrcRange<Dst, Src>::value ==
284 template <typename Dst,
286 IsNumericRangeContained<Dst, T>::value>::type* = nullptr>
287 constexpr operator Dst() const {
288 return static_cast<typename ArithmeticOrUnderlyingEnum<Dst>::type>(value_);