logoalt Hacker News

poppadom1982last Tuesday at 7:39 AM1 replyview on HN

I'm not sure what you're getting at but

const bool z = (const bool)((int8_t)2);

Is perfectly valid C++.


Replies

debugniklast Tuesday at 8:12 AM

That's a conversion, not the same. The naive equivalent to transmute would be

    int8_t x = 2;
    bool y = *reinterpret_cast<bool *>(&x);
But reinterpret_cast isn't valid in a constexpr scope.
show 2 replies