mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
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:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user