Skip to content
  • Mark OLESEN's avatar
    ENH: add factory method readContents to IO containers · f75af788
    Mark OLESEN authored
    - useful when regular contents are to be read via an IOobject and
      returned.
    
      Eg,  dictionary propsDict(IOdictionary::readContents(dictIO));
      vs.  dictionary propsDict(static_cast<dictionary&&>(IOdictionary(dictIO)));
    
      Commonly these would have simply been constructed directly as the
      IO container:
    
      eg,  IOdictionary propsDict(dictIO);
    
      However, that style may not ensure proper move semantics for return
      types.
    
      Now,
      =====
          labelList decomp(labelIOList::readContents(io));
          ... something
          return decomp;
      =====
    
      Previously,
      =====
          labelIOList decomp(io);
    
          // Hope for the best...
          return decomp;
    
          // Or be explicit and ensure elision occurs...
          return labelList(std::move(static_cast<labelList&>(decomp)));
      =====
    
      Note:
           labelList list(labelIOList(io));
    
           looks like a good idea, but generally fails to compile
    f75af788