You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tinyexpr++ project is very good, thank you for maintaining a C++ version.
In my personal use, I found that the custom function can only support up to 7 parameters, and I actually need more. After carefully reading the code of tinyexpr.h, I found the specific reason: because the code uses std::variant to store the specific type of var, and only up to 7 input parameters are defined for the function.
However, I found some bad code smells here. The underline index of the type is used to locate the concrete type of te_variant_type, which makes it not easy to expand the number of args:
I spent some time rewriting this code using some simple template techniques. Now it should be easier to upgrade the maximum args of a function/closure.
The text was updated successfully, but these errors were encountered:
I don't know if I would call it a code smell necessarily. Using variant indices is OK as long as you don't intend to change the variant data type. I was planning on capping the arguments to 7, so that was the case. Using indices like this provides a small optimization, although admittedly nothing too drastic.
Another issue is the built-in variadic functions like SUM. Those are hard coded to 7 arguments because I have to review each argument to see if they are NaN or not. If I expand support to 24 parameters, then those will all need to be updated too. I'll see if I can get that all working with your PR later this week or so...
The tinyexpr++ project is very good, thank you for maintaining a C++ version.
In my personal use, I found that the custom function can only support up to 7 parameters, and I actually need more. After carefully reading the code of
tinyexpr.h
, I found the specific reason: because the code usesstd::variant
to store the specific type of var, and only up to 7 input parameters are defined for the function.If I want to expand it to support more parameters, I need to manually add this part of the code and rewrite
te_variant_type
:However, I found some bad code smells here. The underline index of the type is used to locate the concrete type of
te_variant_type
, which makes it not easy to expand the number of args:I spent some time rewriting this code using some simple template techniques. Now it should be easier to upgrade the maximum args of a function/closure.
The text was updated successfully, but these errors were encountered: