Skip to content

Commit

Permalink
DPL: drop need for has_root_setowner
Browse files Browse the repository at this point in the history
Simple inline constrain is much better.
  • Loading branch information
ktf committed Nov 8, 2024
1 parent 2a8c9c0 commit b345d0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Framework/Core/include/Framework/DataRefUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct DataRefUtils {
// object only depends on the state at serialization of the original object. However,
// all objects created during deserialization are new and must be owned by the collection
// to avoid memory leak. So we call SetOwner if it is available for the type.
if constexpr (has_root_setowner<T>::value) {
if constexpr (requires(T t) { t.SetOwner(true); }) {
result->SetOwner(true);
}
});
Expand Down Expand Up @@ -159,7 +159,7 @@ struct DataRefUtils {
throw runtime_error_f("Unable to extract class %s", cl == nullptr ? "<name not available>" : cl->GetName());
}
// workaround for ROOT feature, see above
if constexpr (has_root_setowner<T>::value) {
if constexpr (requires(T t) { t.SetOwner(true); }) {
result->SetOwner(true);
}
});
Expand Down
17 changes: 0 additions & 17 deletions Framework/Core/include/Framework/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,5 @@ class has_root_dictionary<T, typename std::enable_if<is_container<T>::value>::ty
{
};

// Detect whether a class is a ROOT class implementing SetOwner
// This member detector idiom is implemented using SFINAE idiom to look for
// a 'SetOwner()' method.
template <typename T, typename _ = void>
struct has_root_setowner : std::false_type {
};

template <typename T>
struct has_root_setowner<
T,
std::conditional_t<
false,
class_member_checker<
decltype(std::declval<T>().SetOwner(true))>,
void>> : public std::true_type {
};

} // namespace o2::framework
#endif // FRAMEWORK_TYPETRAITS_H

0 comments on commit b345d0f

Please sign in to comment.