Skip to content

Commit

Permalink
Explicit overload set for safe_value_cache::save.
Browse files Browse the repository at this point in the history
Some older compilers have problems with choosing the right overload when there's a general template vs typed arg functions. So remove template that we know should not match for other overloads.
  • Loading branch information
grafikrobot committed Jan 12, 2024
1 parent f0e6456 commit 82b627a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/engine/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Distributed under the Boost Software License, Version 1.0.

#include "jam.h"
#include "mem.h"
#include "mp.h"
#include "object.h"
#include "output.h"

Expand Down Expand Up @@ -202,14 +203,17 @@ struct value_eq_f

struct safe_value_cache
{
template <typename Test, typename Val, typename... Args>
value_ptr save(Args... args)
template <typename Test, typename Val, typename A0, typename... An>
typename std::enable_if<
!std::is_same<object *, typename mp::remove_cvref<A0>::type>::value,
value_ptr>::type
save(A0 a0, An... an)
{
Test test_val(args...);
Test test_val(a0, an...);
std::lock_guard<std::mutex> guard(mutex);
auto existing = cache.find(&test_val);
if (existing != cache.end()) return *existing;
value_ptr result = Val::make(args...);
value_ptr result = Val::make(a0, an...);
cache.insert(result);
return result;
}
Expand Down

0 comments on commit 82b627a

Please sign in to comment.