Skip to content

Commit b8c6f59

Browse files
committed
DPL: drop need for has_root_setowner
Simple inline constrain is much better.
1 parent 2a8c9c0 commit b8c6f59

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

Framework/Core/include/Framework/DataRefUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct DataRefUtils {
122122
// object only depends on the state at serialization of the original object. However,
123123
// all objects created during deserialization are new and must be owned by the collection
124124
// to avoid memory leak. So we call SetOwner if it is available for the type.
125-
if constexpr (has_root_setowner<T>::value) {
125+
if constexpr (requires(T t) { t.SetOwner(true); }) {
126126
result->SetOwner(true);
127127
}
128128
});
@@ -159,7 +159,7 @@ struct DataRefUtils {
159159
throw runtime_error_f("Unable to extract class %s", cl == nullptr ? "<name not available>" : cl->GetName());
160160
}
161161
// workaround for ROOT feature, see above
162-
if constexpr (has_root_setowner<T>::value) {
162+
if constexpr (requires(T t) { t.SetOwner(true); }) {
163163
result->SetOwner(true);
164164
}
165165
});

Framework/Core/include/Framework/TypeTraits.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,5 @@ class has_root_dictionary<T, typename std::enable_if<is_container<T>::value>::ty
147147
{
148148
};
149149

150-
// Detect whether a class is a ROOT class implementing SetOwner
151-
// This member detector idiom is implemented using SFINAE idiom to look for
152-
// a 'SetOwner()' method.
153-
template <typename T, typename _ = void>
154-
struct has_root_setowner : std::false_type {
155-
};
156-
157-
template <typename T>
158-
struct has_root_setowner<
159-
T,
160-
std::conditional_t<
161-
false,
162-
class_member_checker<
163-
decltype(std::declval<T>().SetOwner(true))>,
164-
void>> : public std::true_type {
165-
};
166-
167150
} // namespace o2::framework
168151
#endif // FRAMEWORK_TYPETRAITS_H

0 commit comments

Comments
 (0)