if we set float and double type to NaN then they are not equal to anything including themselves.
can such a thing happens for
Although it's certainly unusual, C++ does allow int to be NaN.
First, it's possible for int to store information besides its numeric value. §3.9.1/1:
For character types, all bits of the object representation participate in the value representation. For unsigned character types, all possible bit patterns of the value representation represent numbers. These requirements do not hold for other types.
Then, numeric_limits and has_signaling_NaN are not required to be false for any type. §18.2.1.2/34-36:
static const bool has_quiet_NaN;34 True if the type has a representation for a quiet (non-signaling) ‘‘Not a Number.’’
35 Meaningful for all floating point types.
36 Shall be true for all specializations in which is_iec559 != false.
"Meaningful for all floating point types" is a little troublesome as it opens the possibility that the value could be meaningless, but that's certainly an extrapolation.
If numeric_limits, then numeric_limits returns such a value.
Obviously, this is not something you should worry about in your code.