mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: explicit convert to bool operator for autoPtr
- behaves the same as the valid() method, but can be queried directly
like a normal raw pointer and as per std::unique_ptr.
Eg,
autoPtr<T> ptr = ...
if (ptr) ...
This commit is contained in:
@ -234,6 +234,8 @@ public:
|
||||
operator const T&() const = delete;
|
||||
#endif
|
||||
|
||||
//- True if the managed pointer is non-null
|
||||
explicit inline operator bool() const noexcept;
|
||||
|
||||
//- Transfer object ownership from parameter
|
||||
inline void operator=(autoPtr<T>&& ap) noexcept;
|
||||
|
||||
@ -260,6 +260,13 @@ inline const T& Foam::autoPtr<T>::operator()() const
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::autoPtr<T>::operator bool() const noexcept
|
||||
{
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::autoPtr<T>::operator=(autoPtr<T>&& ap) noexcept
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user