ENH: add tmp/refPtr support for setting cref/ref from pointer

- makes it easier to use for local or alternative storage.
  Eg,

  ```
      tmp<volScalarField> tfld;

      tfld.cref(obj.cfindObject<volScalarField>("name"));

      if (!tfld)
      {
          tfld = volScalarField::New("name", ...);
      }
  ```
This commit is contained in:
Mark Olesen
2021-06-08 13:51:49 +02:00
parent e2c8b0b13f
commit 6120e13d29
6 changed files with 71 additions and 7 deletions

View File

@ -85,6 +85,12 @@ int main()
ptr.reset(new scalarField(5, scalar(15)));
tfld3.reset(std::move(ptr));
printInfo(tfld3, true);
ptr.reset(new scalarField(2, scalar(1)));
Info<< nl << "const-ref from pointer: " << name(ptr.get()) << nl;
tfld3.cref(ptr.get());
printInfo(tfld3, true);
}
Info<< "\nEnd" << endl;