I have written some type conversion operators which only make sense in the context of a subset of types.
An example is below
explicit virtual operator DataId<float>() const
{
static_assert(std::is_same_v<T, DataId<float>>, "std::is_same_v<T, DataId<float>>");
return data; // T data
}
This class contains an object of type T=DataId<U>
, where U=float, int, double, std::string
.
static_assert
seems to demand that the argument passed to it to create the error message is a const char*
.
Is there a way to print the type of T
in the message?
I tried, but failed, with this attempt:
constexpr auto message(
(std::string("std::is_same_v<T=") + typeid(T).name() + ", DataId<float>>").c_str()
);
static_assert<..., message>;