mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Make get() return a pointer instead of a reference
This is more in line with how std::unique_ptr works.
This commit is contained in:
parent
d9c6ecf79d
commit
cedb92c6d2
@ -165,14 +165,14 @@ class BlackOilIntensiveQuantities
|
|||||||
CopyablePtr() : ptr_(nullptr) {}
|
CopyablePtr() : ptr_(nullptr) {}
|
||||||
CopyablePtr(const CopyablePtr& other) {
|
CopyablePtr(const CopyablePtr& other) {
|
||||||
if (other) { // other does not contain a nullptr
|
if (other) { // other does not contain a nullptr
|
||||||
ptr_ = std::make_unique<T>(other.get());
|
ptr_ = std::make_unique<T>(*other.get());
|
||||||
}
|
}
|
||||||
// else {ptr_ = nullptr;} // this is the default construction value
|
// else {ptr_ = nullptr;} // this is the default construction value
|
||||||
}
|
}
|
||||||
// assignment operator
|
// assignment operator
|
||||||
CopyablePtr<T>& operator=(const CopyablePtr<T>& other) {
|
CopyablePtr<T>& operator=(const CopyablePtr<T>& other) {
|
||||||
if (other) {
|
if (other) {
|
||||||
ptr_ = std::make_unique<T>(other.get());
|
ptr_ = std::make_unique<T>(*other.get());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ptr_ = nullptr;
|
ptr_ = nullptr;
|
||||||
@ -191,7 +191,7 @@ class BlackOilIntensiveQuantities
|
|||||||
return ptr_ ? true : false;
|
return ptr_ ? true : false;
|
||||||
}
|
}
|
||||||
// get a reference to the stored value
|
// get a reference to the stored value
|
||||||
T& get() const {return *ptr_;}
|
T* get() const {return ptr_.get();}
|
||||||
T* release() const {return ptr_.release();}
|
T* release() const {return ptr_.release();}
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<T> ptr_;
|
std::unique_ptr<T> ptr_;
|
||||||
|
Loading…
Reference in New Issue
Block a user