This question is partly common to C++ Get name of type in template .
I am trying to come up with a template/macro that expand to static_assert(std::is_trivially_destructible<T>::value, #T" is not trivally destructible");
so that I can use a shorthand in my code. But looks like there is no compile time way of knowing the name of T in a template.
The other approach of using a macro is also not good since it will move the errors to incorrect line numbers (i.e. within the macro). See example of errors with a macro as below:
macro.cpp:5:17: error: static assertion failed: std::vector<int> should be trivial
static_assert(std::is_trivially_destructible<T>::value, #T" should be trivial");
^~~
macro.cpp:10:3: note: in expansion of macro ‘STATIC_ASSERT_TRIVIALLY_DESTRUCTIBLE’
STATIC_ASSERT_TRIVIALLY_DESTRUCTIBLE(std::vector<int>);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~