Skip to content
  • Mark OLESEN's avatar
    ENH: add const_cast variants for isA<> and refCast<> · 92c329a8
    Mark OLESEN authored
    - an example of the new, more succinct refConstCast version:
    
          auto& abc = refConstCast<adjointVectorBoundaryCondition>(Uab);
    
      older:
          adjointVectorBoundaryCondition& abc =
              refCast<adjointVectorBoundaryCondition>
              (
                  const_cast<fvPatchVectorField&>(Uab)
              );
      or:
          adjointVectorBoundaryCondition& abc =
              const_cast<adjointVectorBoundaryCondition&>
              (
                  refCast<const adjointVectorBoundaryCondition>(Uab)
              );
    
    - an example of the new, more succinct isA_constCast version:
    
          auto* acapPtr = isA_constCast<fieldType>(abf[patchi]);
    
          if (acapPtr)
          {
              auto& acap = *acapPtr;
              ...
          }
    
      older:
          if (isA<fieldType>(abf[patchi]))
          {
              fieldType& acap =
                  const_cast<fieldType&>
                  (
                      refCast<const fieldType>(abf[patchi])
                  );
              ...
          }
    
    STYLE: remove spurious 'const' qualifier from isA<> use
    92c329a8