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:
Mark Olesen
2020-11-19 12:40:47 +01:00
parent 07bbae0c55
commit 6e3bc1f7d0
13 changed files with 61 additions and 39 deletions

View File

@ -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());
}