mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: can add compile-time deprecated message for autoPtr::set()
- deprecated Feb-2018, but not marked as such. The set() method originally enforce an additional run-time check (Fatal if pointer was already set), but this was rarely used. In fact, the set() method was invariably used in constructors where the pointer by definition was unset. Can now mark as deprecated to catch the last of these. We prefer reset() for similarity with std::unique_ptr Eg, FOAM_EXTRA_CXXFLAGS="-DFoam_autoPtr_deprecate_setMethod" wmake
This commit is contained in:
@ -25,6 +25,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// #define Foam_autoPtr_deprecate_setMethod
|
||||
|
||||
#include <memory>
|
||||
#include "autoPtr.H"
|
||||
#include "labelList.H"
|
||||
@ -236,6 +238,11 @@ int main(int argc, char *argv[])
|
||||
// Does compile (good!): ptr1 = nullptr;
|
||||
|
||||
ptr1.reset(std::move(ptr2));
|
||||
|
||||
autoPtr<labelList> ptr3;
|
||||
|
||||
// set() method - deprecated warning?
|
||||
ptr3.set(ptr1.release());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user