File tree Expand file tree Collapse file tree
packages/react-native-executorch/common/rnexecutorch Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,4 +13,7 @@ concept HasGenerate = requires(T t) {
1313 { &T::generate };
1414};
1515
16+ template <typename T>
17+ concept IsNumeric = std::is_arithmetic<T>::value;
18+
1619} // namespace rnexecutorch
Original file line number Diff line number Diff line change @@ -21,14 +21,12 @@ using namespace facebook;
2121
2222template <typename T> T getValue (const jsi::Value &val, jsi::Runtime &runtime);
2323
24- template <>
25- inline double getValue<double >(const jsi::Value &val, jsi::Runtime &runtime) {
26- return val.asNumber ();
27- }
28-
29- template <>
30- inline int getValue<int >(const jsi::Value &val, jsi::Runtime &runtime) {
31- return val.asNumber ();
24+ template <typename T>
25+ requires IsNumeric<T>
26+ inline T getValue (const jsi::Value &val, jsi::Runtime &runtime) {
27+ static_assert (std::is_integral<T>::value || std::is_floating_point<T>::value,
28+ " Only integral and floating-point types are supported" );
29+ return static_cast <T>(val.asNumber ());
3230}
3331
3432template <>
You can’t perform that action at this time.
0 commit comments