Skip to content
  • Mark Olesen's avatar
    ENH: provide refOrNull method for autoPtr. · 6d7ff59f
    Mark Olesen authored
    - Normally use '()' to deference. This has extra safety and issues a
      fatal error if the underlying pointer is not valid.
    
      However, in some cases we are happy with getting a null reference.
      The refOrNull() method returns the reference without any checking.
    
      Usage example:
    
          autoPtr<OFstream> osPtr;
          if (Pstream::master())
          {
              osPtr.reset(new OFstream(...));
          }
          writeViaMaster(osPtr.refOrNull());
    
          - The writeViaMaster() call takes an OFstream reference,
            but this is only used directly on the master.
            The slaves will pass things through to the master.
    6d7ff59f