Strictly speaking, this is only valid if
```c++
std::numeric_limits<Scalar>::has_quiet_NaN == true
```
Do you test for that condition elsewhere?