I have a computational graph g that takes a certain number of "Variable" parameters (defined at runtime) I want to be able to use this graph like a function like :
auto a = g(x, y);
but that's not possible as the number of parameters is defined at runtime I would have to change the function so it accepts a vector of Variable instead and maybe do something like :
auto a = g({x, y});
but that's not very user friendly so I thought I could overload an operator of Variable so it automatically make a list and use it like :
auto a = g(x + y);
//or
auto a = g(x ^ y);
//or
auto a = g(x && y);
but that would be even more confusing. then I found that there is a comma operator that can be overloaded
auto a = g(x, y);
EDIT 1
attempt to a clearer explanation : g() could take a variable number of parameters but this number is only defined at runtime (the parameters are all of type "Variable") that is impossible in C++, that's why I want to "simulate" it : g() will actually take a vector of "Variable" as input and I want to overload the comma operator so that it packs the "Variable" into a vector
EDIT 2
I found an example of that in Boost.Assign :
vector<int> v;
v += 1,2,3,4,5,6,7,8,9;
the commas are overloaded so that this works like {1,2,3,4,5,6,7,8,9}
EDIT 3
I tried to implement it and it doesn't work like I wanted because of the priority of operators : you have to write
auto a = g( (A, B, C) );
otherwise you get a compiler error : too many parameters
/EDIT
that seems too good to be true, before I start trying to implement it, is that even possible in the first place ? it seems a bit "hacky" is that a good practice ? or is there a way better alternative ?
I saw other methods that do that kind of thing but they are usually 10 times more complex using variadic templates and boost::any...