Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ROwningPtr no pointer template type
  • Loading branch information
guitargeek committed Dec 7, 2023
commit 43c8cafcf7e1dbb1a4fdc0382c9ebad381c1d03d
10 changes: 5 additions & 5 deletions core/foundation/inc/ROOT/ROwningPtr.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
#include <memory>
namespace ROOT {

template <typename T, typename = std::enable_if_t<std::is_pointer<T>::value>>
template <typename T>
class ROwningPtr {
public:
using pointer = T;
using pointer = T *;
using element_type = typename std::remove_pointer<pointer>::type;
using reference = typename std::add_lvalue_reference<element_type>::type;

ROwningPtr(T ptr) : _ptr{ptr} {}
ROwningPtr(T *ptr) : _ptr{ptr} {}

operator pointer() { return _ptr; }
operator std::unique_ptr<element_type>() { return std::unique_ptr<element_type>{_ptr}; }
Expand All @@ -36,8 +36,8 @@ public:
pointer operator->() const { return _ptr; }

private:
T _ptr;
T *_ptr;
};

} // namespace ROOT
#endif
#endif
6 changes: 3 additions & 3 deletions io/io/inc/TFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ class TFile : public TDirectoryFile {
*AsyncOpen(const char *name, Option_t *option = "",
const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
Int_t netopt = 0);
static ROOT::ROwningPtr<TFile *> Open(const char *name, Option_t *option = "", const char *ftitle = "",
Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
Int_t netopt = 0);
static ROOT::ROwningPtr<TFile> Open(const char *name, Option_t *option = "", const char *ftitle = "",
Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
Int_t netopt = 0);
static TFile *Open(TFileOpenHandle *handle);

static EFileType GetType(const char *name, Option_t *option = "", TString *prefix = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion io/io/src/TFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4068,7 +4068,7 @@ TFile *TFile::OpenFromCache(const char *name, Option_t *, const char *ftitle,
/// In RECREATE mode, a nullptr is returned if the file can not be created.
/// In UPDATE mode, a nullptr is returned if the file cannot be created or opened.

ROOT::ROwningPtr<TFile *>
ROOT::ROwningPtr<TFile>
TFile::Open(const char *url, Option_t *options, const char *ftitle, Int_t compress, Int_t netopt)
{
TPluginHandler *h;
Expand Down