Article 4SWRM C++: passing list of functions as argument to function

C++: passing list of functions as argument to function

by
rdx
from LinuxQuestions.org on (#4SWRM)
This is really a pure C++ question (g++).
I want to pass a list of functions to another function so that it can call those in the list in sequence and accumulate their outputs in a matrix. The functions in the list are "double (*func)( vec x)" in the syntax of the Armadillo linear algebra library.

This is similar I think to the way hardware drivers used to have a list of function calls to access "read," "write," and control functions but I haven't seen that usage in a long time.

What I am trying to do is pass the pointers as "uwords" since that is a type acceptable to Armadillo and then cast the unsigned long ints to function calls. If this seems too awkward I would fall back on a STL <vector> to contain the list. Other ideas welcomed. The key feature here is that the number of functions in the list is arbitrary.latest?d=yIl2AUoC8zA latest?i=XxIliX45GWM:MSlalBr-Bcc:F7zBnMy latest?i=XxIliX45GWM:MSlalBr-Bcc:V_sGLiP latest?d=qj6IDK7rITs latest?i=XxIliX45GWM:MSlalBr-Bcc:gIN9vFwXxIliX45GWM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments