work around bug in gcc 4.8

This commit is contained in:
Davis King 2021-01-16 10:13:52 -05:00
parent 869097c809
commit 600e036552
2 changed files with 30 additions and 1 deletions

View File

@ -281,12 +281,31 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
std::vector<function_spec> specs,
const std::chrono::nanoseconds max_runtime,
const max_function_calls num,
double solver_epsilon = 0,
double solver_epsilon,
Args&& ...args
)
{
return find_max_global(ymult, tp, functions, std::move(specs), num, max_runtime, solver_epsilon, std::forward<Args>(args)...);
}
// This overload shouldn't be required but it works around a bug in gcc 4.8 which has a bug
// that makes it complain about setting a default for solver_epsilon but then following it
// by args that "isn't defaulted" according to gcc 4.8.
template <
typename funct,
typename ...Args
>
std::pair<size_t,function_evaluation> find_max_global (
double ymult,
thread_pool& tp,
std::vector<funct>& functions,
std::vector<function_spec> specs,
const std::chrono::nanoseconds max_runtime,
const max_function_calls num,
double solver_epsilon = 0
)
{
return find_max_global(ymult, tp, functions, std::move(specs), num, max_runtime, solver_epsilon);
}
// This overload allows the num argument to be skipped.
template <

View File

@ -187,6 +187,16 @@ namespace
DLIB_TEST_MSG(max(abs(true_x-result.x)) < 1e-5, max(abs(true_x-result.x)));
print_spinner();
result = find_max_global(rosen, {0.1, 0.1}, {2, 2}, std::chrono::seconds(5), max_function_calls(100));
dlog << LINFO << "rosen: " << trans(result.x);
DLIB_TEST_MSG(max(abs(true_x-result.x)) < 1e-5, max(abs(true_x-result.x)));
print_spinner();
result = find_max_global(rosen, {0.1, 0.1}, {2, 2}, max_function_calls(100), std::chrono::seconds(5));
dlog << LINFO << "rosen: " << trans(result.x);
DLIB_TEST_MSG(max(abs(true_x-result.x)) < 1e-5, max(abs(true_x-result.x)));
print_spinner();
result = find_max_global(rosen, {0.1, 0.1}, {2, 2}, {false,false}, max_function_calls(100));
dlog << LINFO << "rosen: " << trans(result.x);