Meaning of constructor with multiple pairs of parentheses
The parameter of the constructor
someClass( std::list<std::function<void(std::vector<someType>&)>>(&)(const std::vector<someType>&)) {
is a reference to a function that has the return type std::list<std::function<void(std::vector<someType>&)>>
and one parameter of the type const std::vector<someType>&
It is a function by itself.
std::list<
std::function<
void(std::vector<someType>&)
>
> (&)(const std::vector<someType>&)
This is a reference to a function that takes as an argument a reference to const std::vector
of someType
and returns a list of std::function
s that take a reference to a std::vector
of someType
and return void
.
Usage example:
#include <vector>
#include <list>
#include <functional>
class someType {};
void func(std::list<std::function<void(std::vector<someType>&)>> (& par)(const std::vector<someType>&)) {
// some input
const std::vector<someType> input;
// the function returns the list
std::list<std::function<void(std::vector<someType>&)>> res = par(input);
// we can iterate over the list
for (auto & i : res) {
std::vector<someType> other;
// and call the functions inside
i(other);
}
}