diff --git a/core/thread/inc/ROOT/TThreadedObject.hxx b/core/thread/inc/ROOT/TThreadedObject.hxx index 8078a6664b01f94a229a3689c0929f9dc26640ff..b7c95b435ae9dd61e6396cc57e350215304cf78e 100644 --- a/core/thread/inc/ROOT/TThreadedObject.hxx +++ b/core/thread/inc/ROOT/TThreadedObject.hxx @@ -41,7 +41,7 @@ namespace ROOT { } /// Return a copy of the object or a "Clone" if the copy constructor is not implemented. - template<class T, bool isCopyConstructible = std::is_copy_constructible<T>::value> + template<class T, bool isCopyConstructible = std::is_copy_constructible<T>::value, bool ISHISTO = std::is_base_of<TH1,T>::value> struct Cloner { static T *Clone(const T *obj, TDirectory* d = nullptr) { T* clone; @@ -56,7 +56,7 @@ namespace ROOT { }; template<class T> - struct Cloner<T, false> { + struct Cloner<T, false, false> { static T *Clone(const T *obj, TDirectory* d = nullptr) { T* clone; if (d){ @@ -69,6 +69,20 @@ namespace ROOT { } }; + template<class T> + struct Cloner<T, true, true> { + static T *Clone(const T *obj, TDirectory* d = nullptr) { + T* clone; + if (d){ + clone = (T*)obj->Clone(); + } else { + clone = (T*)obj->Clone(); + } + clone->SetDirectory(nullptr); + return clone; + } + }; + template<class T, bool ISHISTO = std::is_base_of<TH1,T>::value> struct DirCreator{ static std::vector<TDirectory*> Create(unsigned maxSlots) {