Commit Graph

10 Commits

Author SHA1 Message Date
Mark Olesen
6a1efe3b5c ENH: support construct/reset refPtr from autoPtr and unique_ptr (#1775)
- makes it easier to use in combination with various 'New' selectors,
  which mostly return an autoPtr.

ENH: add very simple FFT test

- basic sanity test that the library links properly
2020-08-11 13:15:28 +02:00
Mark Olesen
677e314279 string trim 2019-12-13 10:05:28 +01:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
3c07a1bb6f ENH: Foam::name() of memory address
- returns the memory address formatted in hexadecimal, which can be
  useful for detailed information
2019-08-12 10:46:29 +02:00
Mark Olesen
59da4cf56d STYLE: use uintptr_t cast instead of long when reporting addresses 2019-04-29 08:15:48 +02:00
Mark Olesen
e3e0d7c8b9 ENH: add possibility to change const reference in tmp.
- previously it was only possible to reset a pointer, but not to
  change a const-reference directly (needed a swap() to do this).
2019-02-11 18:23:06 +01:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
08335beb6f ENH: add get() accessor to tmp classes
- similar to autoPtr and unique_ptr. Returns the pointer value without
  any checks. This provides a simple way for use to use either
  an autoPtr or a tmp for local memory management without accidentally
  stealing the pointer.

  Eg,

     volVectorField* ptr;
     tmp<volVectorField> tempField;

     if (someField.valid())
     {
         ptr = someField.get();
     }
     else
     {
         tempField.reset(new volVectorField(....));
         ptr = tmpField.get();
     }

     const volVectorField& withField = *ptr;

STYLE: make more tmp methods noexcept
2018-12-20 17:29:51 +01:00
Mark Olesen
52b36f84b5 ENH: cleanup tmp class (issue #639)
Improve alignment of its behaviour with std::shared_ptr

  - element_type typedef
  - swap, reset methods

* additional reference access methods:

cref()
    returns a const reference, synonymous with operator().
    This provides a more verbose alternative to using the '()' operator
    when that is desired.

        Mnemonic: a const form of 'ref()'

constCast()
    returns a non-const reference, regardless if the underlying object
    itself is a managed pointer or a const object.
    This is similar to ref(), but more permissive.

        Mnemonic: const_cast<>

    Using the constCast() method greatly reduces the amount of typing
    and reading. And since the data type is already defined via the tmp
    template parameter, the type deduction is automatically known.

    Previously,

        const tmp<volScalarField>& tfld;

        const_cast<volScalarField&>(tfld()).rename("name");
        volScalarField& fld = const_cast<volScalarField&>(tfld());

    Now,

        tfld.constCast().rename("name");
        auto& fld = tfld.constCast();

--

BUG: attempts to move tmp value that may still be shared.

- old code simply checked isTmp() to decide if the contents could be
  transfered. However, this means that the content of a shared tmp
  would be removed, leaving other instances without content.

* movable() method checks that for a non-null temporary that is
  unique (not shared).
2018-02-26 12:05:00 +01:00