[petsc-dev] wrong PETSc code, please read the PETSc style guide

Barry Smith bsmith at mcs.anl.gov
Mon Sep 17 20:42:15 CDT 2012


  Right, I forget. Yes C++ sucks.  Right these ! checks are for non-PETScScalar variables.


On Sep 17, 2012, at 8:38 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:

> On Mon, Sep 17, 2012 at 8:27 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> So it is ok to do  if (fl == 0.0)   but not (!fl)?  How are they different?
> 
> It means the wrong thing in C++. Specifically, it tries to convert the number to bool since there is no std::complex<T>::operator!(T), but std::complex does not provide a conversion to bool either. This produces errors like
> 
> error: invalid argument type 'std::complex<double>' to unary expression




More information about the petsc-dev mailing list