chsvlib
chsv helper source code

◆ ForEachRow()

void ForEachRow ( FunctorType &&  fn,
Args &&...  args 
) const

Performs enumeration of rows of a matrix with respect to its parallelism policy, and calls a client's Callable object for each of the rows.

Template Parameters
FunctorTypeA type of the client's Callable object, i.e. a function, a pointer to function, a method, a lambda, etc. Since ForEachRow passes an additional argument 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 second parameter position. See fn description below.
Parameters
fnis a Callable object passed to the method by a client. The object, of type FunctorType, is expected to process the rows 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 parameter passed by the implementation of ForEachRow to fn is an index if a row to process. I.e. the calls are made in the following forms.
std::forward<FunctorType>(fn)(iRow, std::forward<Args>(args)...); //for a function object
(std::forward<Arg1>(arg1).*fn)(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)(iRow, std::forward<Args2_n>(args2_n)...); //The same, but if Arg1 is std::reference_wrapper
Here iRow is an index of a row being enumerated, and args is a pack of parameters given by the client as the second parameter of the ForEachRowSetPolicy method with respect to the Args type pack. The integral iRow is of the size_type type.
argsis a parameter pack for the callable fn defined by the client.

A similar ForEachRowSetPolicy method allows enumerating the rows with an explicitly defined policy towards parallel execution independently of policy settings of the matrix.

Exceptions
std::system_errorAny of the parallel threads could not be started.