void ForEachElement | ( | FunctorType && | fn, |
Args &&... | args | ||
) | const |
Performs enumeration of elements of a matrix with respect to its parallelism policy, and calls a client's Callable object for each element of the matrix.
FunctorType | A type of the client's Callable object, i.e. a function, a pointer to function, a method, a lambda, etc. Since ForEachElement passes additional arguments to the callable, the type cannot be a class data member. See fn description for the requirements. |
Args... | A type pack of additional arguments passed directly to the callable object starting from the third parameter position. See fn description below. |
fn | is a Callable object passed to the method by a client. The object, of type FunctorType , is expected to process the elements independently of one another both in parallel and in sequential mode, since the order of calls to the object is unspecified. The scheme of calling the object is given in the description of Callable. Additionally, the first two parameters passed by the implementation of ForEachElement to fn are indices if a column and a row of an element to process respectively. I.e. the calls are made in the following forms. std::forward<FunctorType>(fn)(iColumn, iRow, std::forward<Args>(args)...); //for a function object
(std::forward<Arg1>(arg1).*fn)(iColumn, iRow, std::forward<Args2_n>(args2_n)...); //for a pointer to a method of a class object arg1 of type Arg1 where
//Arg1 is the first type of the pack Args, arg1 is the corresponding parameter; Args2_n - types of the pack Args excluding the first one, args2_n
//is a corresponding pack of arguments.
(arg1.get().*fn)(iColumn, iRow, std::forward<Args2_n>(args2_n)...); //The same, but if Arg1 is std::reference_wrapper
iColumn is an index of a column of the currently enumerated matrix element, and iRow is an index of the its row, and args is a pack of parameters given by the client as the third parameter of the ForEachElementSetPolicy method with respect to the Args type pack. The integrals iColumn and iRow are of the size_type type. |
args | is a parameter pack for the callable fn defined by the client. |
A similar ForEachElementSetPolicy method allows enumerating the elements with an explicitly defined policy towards parallel execution independently of policy settings of the matrix.
std::system_error | Any of the parallel threads could not be started. |