utx::gnrk_static_cast - Utxcpp Generic Static Cast.
utx::gnrk_static_cast tries to static_cast types as more as possible: utx::meric_static_cast, simple-constructible-with cast, and static_cast .
utx::gnrk_static_cast rules over three casts:
#include <utxcpp/core.hpp> int main() { constexpr utx::ix32 a = 123; constexpr auto b = utx::gnrk_static_cast<utx::fx64>(a); // It calls utx::meric_static_cast internally utx::print(a, b); // 123 123.0 constexpr float c = 3.4; constexpr auto d = utx::gnrk_static_cast<int>(c); // It calls static_cast internally utx::print(c, d); // 3.4 3 class cat_box { private: utx::ix32 value; public: constexpr cat_box(const utx::ix32 & value): value{value} { } constexpr auto operator()() const { return value; } }; constexpr utx::ix32 e = 234; constexpr auto f = utx::gnrk_static_cast<cat_box>(e); // It calls target_type{value__} internally utx::print(e, f()); // 234 234 utx::ix32 g = 345; decltype(auto) h = utx::gnrk_static_cast<utx::ix32 &>(g); ++h; utx::print(g, h); // 346 346 }