I find myself reaching for this function all the time and re-implementing it. Maybe it makes sense to add to util/check.h and eventually replace uses of static_assert with this to save contributor time when diagnosing failing static_asserts.
The benefit of
static_check_equal(1, 2)
is that it prints 1 and 2 in the compiler error.
./util/check.h: In instantiation of ‘static_check_equal_struct<T1, T2, value_1, value_2>::static_check_equal_struct() [with T1 = int; T2 = int; T1 value_1 = 1; T2 value_2 = 2]’:
txmempool.cpp:29:5: required from here
./util/check.h:63:31: error: static assertion failed: Equality check failed, value_1 != value_2.
63 | static_assert(value_1 == value_2, "Equality check failed, value_1 != value_2.");
Compare to:
static_assert(sizeof(int) == sizeof(size_t))
which just gives
txmempool.cpp:29:31: error: static assertion failed
29 | static_assert(sizeof(int) == sizeof(size_t));
is that you don't actually get to see what size T and T2 actually are, which can make it annoying to debug what went wrong, so then you end up guessing and recompiling or having to run the code to print the size out.