Skip to content

Commit d730565

Browse files
committed
[hist] Prepare for overloaded AtomicAdd member functions
With the previous code, the compiler would complain: decltype cannot resolve address of overloaded function For regular overloaded functions, it is possible to pass the expected argument type (using std::declval), but not for member functions: cannot call member function [...] without object Instead use auto and trailing return type from C++11 to select the right set of dispatch functions.
1 parent 58bc18f commit d730565

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

hist/histv7/inc/ROOT/RHistUtils.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ std::enable_if_t<std::is_arithmetic_v<T>> AtomicInc(T *ptr)
197197
}
198198

199199
template <typename T, typename U>
200-
std::enable_if_t<std::is_member_function_pointer_v<decltype(&T::AtomicAdd)>> AtomicAdd(T *ptr, const U &add)
200+
auto AtomicAdd(T *ptr, const U &add) -> decltype(ptr->AtomicAdd(add))
201201
{
202-
ptr->AtomicAdd(add);
202+
return ptr->AtomicAdd(add);
203203
}
204204

205205
template <typename T>
206-
std::enable_if_t<std::is_member_function_pointer_v<decltype(&T::AtomicInc)>> AtomicInc(T *ptr)
206+
auto AtomicInc(T *ptr) -> decltype(ptr->AtomicInc())
207207
{
208-
ptr->AtomicInc();
208+
return ptr->AtomicInc();
209209
}
210210

211211
} // namespace Internal

0 commit comments

Comments
 (0)