Trying to create a constexpr capable class that reinterprets the bits of an IEEE double. Example:
constexpr double pi = 3.14159265358979323846;
constexpr fixedpoint a(pi);
However, running into the problem that reinterpret_cast is not a constant subexpression.
I am using this in the constexpr fixedpoint& operator=(double rhs) :
uint64_t fraction = *reinterpret_cast<const uint64_t*>(&rhs) & 0x000F'FFFF'FFFF'FFFFull;
but the compiler flags that statement as a non-constant subexpression.
Tried type punning but that ran into the constraint that in C++ only a single field can be active.
Any one have a solution that allows me to reinterpret the bits of that double that is valid constexpr code?