utx::same_assert and utx::same_strip_assert are used to test if two types are the same or not the same. They are alias template, being useful at compile-time.
utx::same_assert<t1, t2>()
is the shorthand combination of static_assert(std::same_as<t1, t2>)
utx::same_strip_assert<t1, t2>()
is the shorthand combination of static_assert(std::same_as<std::remove_cvref_t<t1>, std::remove_cvref_t<t2>>)
utx::same_assert<type_xt, type_yt, true>();
utx::same_assert<type_xt, type_yt, false>();
utx::same_assert<type_xt, type_yt>(); // Default true
utx::same_assert is alias template of class utx::same_assert_class, whose constructor is consteval, and static_assert is evaluated at its constructor.
utx::same_strip_assert<type_xt, type_yt, true>();
utx::same_strip_assert<type_xt, type_yt, false>();
utx::same_strip_assert<type_xt, type_yt>(); // Default true
utx::same_strip_assert is alias template of class utx::same_strip_assert_class, whose constructor is consteval, and static_assert is evaluated at its constructor.
The difference between utx::same_strip_assert and utx::same_assert is that
utx::same_strip_assert will apply utx::remove_cvref_t before calling static_assert<utx::same_as<...
.
#include <utxcpp/core.hpp> #include <iostream> int main() { const int & x = 123; utx::same_assert<decltype(x), int, false>(); utx::same_assert<utx::i32, utx::i32>(); utx::same_strip_assert<decltype(x), int, true>(); utx::same_strip_assert<decltype(x), int>(); std::cout << "pass\n"; utx::print("pass"); }