I am programming a function quite like grep -r for a while now and need to return the local variables of my function. The thing is, I am supposed to invoke the function with thread pools using the CTPL library on ubuntu. Anyways, I am posting the function declaration with the given parameters.
std::vector<int>
grep_func(fs::path path_to_search, std::string search_str, std::string logfname, std::string txtfname)
Out of context, this function returns the information about where the searched word is found. The problem is that I am supposed to run this function with thread pools and get the thread IDs in a log file. But I also want to return the searched results to the main or another function to print the results.
I call this function from the main as below. (with the full awareness of it being wrong) Is there a way of achieving this?
ctpl::thread_pool p(num_of_threads);
results = p.push(grep_func(cwd.string(), search, def_log_name, def_txt_name));
./grepx "word" -d [directory_name] -l [log_file] -r [result_file] [-t] [threads]
```4
I
---I this is how I execute the function.