FastLED 3.9.15
Loading...
Searching...
No Matches

◆ operator()() [7/9]

template<typename IntType = i64>
template<typename T = IntType>
fl::enable_if<!fl::is_same< T, i64 >::value, void >::type fl::int_conversion_visitor< IntType >::operator() ( const i64 & value)
inline

Definition at line 176 of file types.h.

176 {
177 // Check for overflow before casting
178 // For signed types: check if value is within [min, max] range
179 // For unsigned types: check if value is non-negative and within [0, max] range
180 // Use parentheses around min/max to protect against Arduino min/max macros
181 const i64 min_val = static_cast<i64>((fl::numeric_limits<IntType>::min)());
182 const i64 max_val = static_cast<i64>((fl::numeric_limits<IntType>::max)());
183
185 // Log overflow error but still perform conversion (value will be truncated)
186 FL_ERROR("JSON integer overflow: value " << value << " does not fit in target type (range: "
187 << min_val << " to " << max_val << "), truncating");
188 }
189
190 // Always perform conversion, even if overflow detected
191 result = static_cast<IntType>(value);
192 }
#define FL_ERROR(X)
Definition log.h:219
fl::optional< IntType > result
Definition types.h:143

References FL_ERROR, FL_NOEXCEPT, fl::numeric_limits< T >::max(), fl::numeric_limits< T >::min(), result, and fl::type_rank< T >::value.

+ Here is the call graph for this function: