/// Josh's 3D Math Library /// A C++20 Library for 3D Math, Computer Graphics, and Scientific Computing. /// Developed and Maintained by Josh O'Leary @ Redacted Software. /// Special Thanks to William Tomasine II and Maxine Hayes. /// (c) 2024 Redacted Software /// This work is dedicated to the public domain. /// @file Reinterpret.h /// @desc Reinterpret one type to another using union hackery. /// @edit 2024-07-06 #pragma once namespace J3ML { /// As per C99, union-reinterpret should now be safe: http://stackoverflow.com/questions/8511676/portable-data-reinterpretation template union ReinterpretOp { From from; To to; ReinterpretOp(From from_) : from(from_) {} // Do not make explicit! operator To() const { return to; } // Do not make explicit! }; template To ReinterpretAs(From input) { //ReinterpretOp fi; //fi.to = input; return ReinterpretOp(input); //fi.from; } }