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 @@ -18,14 +18,12 @@ using namespace facebook;
1818
1919template <typename T> T getValue (const jsi::Value &val, jsi::Runtime &runtime);
2020
21- template <>
22- inline double getValue<double >(const jsi::Value &val, jsi::Runtime &runtime) {
23- return val.asNumber ();
24- }
25-
26- template <>
27- inline int getValue<int >(const jsi::Value &val, jsi::Runtime &runtime) {
28- return val.asNumber ();
21+ template <typename T>
22+ requires IsNumeric<T>
23+ inline T getValue (const jsi::Value &val, jsi::Runtime &runtime) {
24+ static_assert (std::is_integral<T>::value || std::is_floating_point<T>::value,
25+ " Only integral and floating-point types are supported" );
26+ return static_cast <T>(val.asNumber ());
2927}
3028
3129template <>
You can’t perform that action at this time.
0 commit comments