On Friday, 28 October 2016 at 03:33:33 UTC, Basile B. wrote:
Hello, I think the correct isStringLiteral would be:
import
std.meta;
template isStringLiteral(alias V)
{
enum isCompileTime = is(typeof((){enum a = V;}));
enum isString = is(typeof(V) == string);
enum isStringLiteral = isCompileTime && isString;
}
It works, Thanks. Also, i don't think in my case there is the
need for a variant for types( aka isStringLiteral(V) without
alias) because it's an error to pass a type to Optimize in first
place. But for a general purpouse library, maybe a template
isLiteral(alias V) that only checks if it is a literal without
the type checking, would have more sense to have also
isLiteral(V) for types that returns always false.
Gianni Pisetta