mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: mark autoPtr copy assigment as '= delete' (#639)
- was marked as transitional/deprecated (2018-02), now deleted. - avoids unexpected stealing of the pointer. Use the move assignment it that is the intention.
This commit is contained in:
@ -48,7 +48,6 @@ SourceFiles
|
|||||||
|
|
||||||
// Transitional features/misfeatures
|
// Transitional features/misfeatures
|
||||||
#define Foam_autoPtr_copyConstruct
|
#define Foam_autoPtr_copyConstruct
|
||||||
#define Foam_autoPtr_copyAssign
|
|
||||||
#define Foam_autoPtr_castOperator
|
#define Foam_autoPtr_castOperator
|
||||||
|
|
||||||
#include "stdFoam.H"
|
#include "stdFoam.H"
|
||||||
@ -227,6 +226,18 @@ public:
|
|||||||
// FatalError if no pointer is managed
|
// FatalError if no pointer is managed
|
||||||
inline const T& operator()() const;
|
inline const T& operator()() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Casting
|
||||||
|
|
||||||
|
//- True if the managed pointer is non-null
|
||||||
|
explicit operator bool() const noexcept { return bool(ptr_); }
|
||||||
|
|
||||||
|
//- Cast to pointer type
|
||||||
|
operator const T*() const noexcept { return ptr_; }
|
||||||
|
|
||||||
|
//- Cast to pointer type
|
||||||
|
operator T*() noexcept { return ptr_; }
|
||||||
|
|
||||||
//- Deprecated(2019-01) Automatic cast conversion to underlying type
|
//- Deprecated(2019-01) Automatic cast conversion to underlying type
|
||||||
// FatalError if no pointer is managed
|
// FatalError if no pointer is managed
|
||||||
// \deprecated(2019-01) Can result in inadvertent conversions
|
// \deprecated(2019-01) Can result in inadvertent conversions
|
||||||
@ -238,14 +249,8 @@ public:
|
|||||||
operator const T&() const = delete;
|
operator const T&() const = delete;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- Cast to pointer type
|
|
||||||
operator const T*() const noexcept { return get(); }
|
|
||||||
|
|
||||||
//- Cast to pointer type
|
// Assignment
|
||||||
operator T*() noexcept { return get(); }
|
|
||||||
|
|
||||||
//- True if the managed pointer is non-null
|
|
||||||
explicit operator bool() const noexcept { return ptr_; }
|
|
||||||
|
|
||||||
//- Transfer object ownership from parameter
|
//- Transfer object ownership from parameter
|
||||||
inline void operator=(autoPtr<T>&& ap) noexcept;
|
inline void operator=(autoPtr<T>&& ap) noexcept;
|
||||||
@ -254,16 +259,9 @@ public:
|
|||||||
template<class U>
|
template<class U>
|
||||||
inline void operator=(autoPtr<U>&& ap) noexcept;
|
inline void operator=(autoPtr<U>&& ap) noexcept;
|
||||||
|
|
||||||
#ifdef Foam_autoPtr_copyAssign
|
//- No move assignment disguised as a copy assignment
|
||||||
//- A move assignment disguised as a copy assignment
|
// \deprecated(2018-02) can have unintended behaviour
|
||||||
// \remark Non-standard definition - should just be movable
|
|
||||||
void operator=(const autoPtr<T>& ap) noexcept
|
|
||||||
{
|
|
||||||
operator=(std::move(const_cast<autoPtr<T>&>(ap)));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void operator=(const autoPtr<T>& ap) = delete;
|
void operator=(const autoPtr<T>& ap) = delete;
|
||||||
#endif
|
|
||||||
|
|
||||||
//- Reset via assignment from literal nullptr
|
//- Reset via assignment from literal nullptr
|
||||||
inline void operator=(std::nullptr_t) noexcept;
|
inline void operator=(std::nullptr_t) noexcept;
|
||||||
|
|||||||
Reference in New Issue
Block a user