#include <memory>
#include <functional>
#include <vector>
class StoppableThread {};
class Source {};
class Population {};
enum class Parameter {A, B};
// the start function
template <typename FunctionResult, typename ...FunctionArgs>
inline std::shared_ptr<StoppableThread> start(
std::function<FunctionResult(const bool&, FunctionArgs...)> function, FunctionArgs... args)
{
return std::shared_ptr<StoppableThread>();
}
int main(int argc, char const *argv[])
{
// defined lambda function
std::function<void(const bool&,
const Source&, Population&,
const std::vector<Parameter>&,
const size_t&, const size_t&)> threadedSearch = [](
const bool& mustStop,
const Source& source, Population& population,
const std::vector<Parameter>& parameters,
const size_t& randomCandidatesCount, const size_t& lineageCount)
{ /* do things here */ };
// define values for later call
Source source;
Population population;
const std::vector<Parameter> parameters = {Parameter::A, Parameter::B};
const size_t randomCandidatesCount = 4;
const size_t lineageCount = 256;
// perform the problematic call
auto searchThread = start(
threadedSearch,
source, population,
parameters,
randomCandidatesCount, lineageCount);
// never got to this point so far
return 0;
}