Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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