void ForEachElementSetPolicy | ( | FunctorType && | fn, |
Args... | args | ||
) | const |
Performs parallel policy-based enumeration of elements of a matrix calling a client's Callable object.
FunctorType | A type of the client's Callable object, i.e. a function, a pointer to function, a method, a lambda, etc. Since ForEachElementSetPolicy 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. |
ParallelismPolicy | A policy marker specifying whether the enumeration should be performed in multiply CPU threads. Possible values are matrix_always_sequential and matrix_always_parallel (but not matrix_dynamically_customizable_parallelism). |
fn | is a Callable object passed to the method by a client. The object, of type FunctorType , is expected to process 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 ForEachElementSetPolicy 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 second 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. |
Unlike ForEachElement, the method enumerates the elements of the matrix using a specifically provided policy.
std::system_error | Any of the parallel threads could not be started. |