On Monday, 7 November 2016 at 18:42:37 UTC, Picaud Vincent wrote:
template isIntegralConstant(ANY)
{
enum bool
isIntegralConstant=__traits(identifier,ANY)=="IntegralConstant";
}
A bit more elegant way of doing that would be:
enum isIntegralConstant(T) = is(T : IntegralConstant!U, U...);
I would be very graceful for any help/advice that explains the
right way to implement C++ std::integral_constant<T,T value> in
the D language.
Vincent
Now the question is, do you really need IntegralConstant? I've
never used it in C++ so I don't really know any of the use cases
for it. But generally in D if you need something to be a compile
time constant value you can just use "enum". It can be any type
as well, so long as it can be evaluated at compile time.
enum long someConstant = 1 << 32;