Files
libart-json/art/json/variant.txx
The Artist 50418b02e4
All checks were successful
on-push / build-and-test (push) Successful in 21s
Hello libart-json
2025-10-18 00:29:14 +02:00

20 lines
651 B
C++

namespace art::json {
template< typename ArithmeticType >
ArithmeticType
variant::get_number() const
{
if constexpr (std::is_arithmetic_v< ArithmeticType >) {
if (std::holds_alternative< long long int >(value_))
return static_cast< ArithmeticType >(std::get< long long int >(value_));
else if (std::holds_alternative< unsigned long long int >(value_))
return static_cast< ArithmeticType >(std::get< unsigned long long int >(value_));
else if (std::holds_alternative< long double >(value_))
return static_cast< ArithmeticType >(std::get< long double >(value_));
}
throw invalid_type{};
}
} // namespace art::json