Skip to content

Instantly share code, notes, and snippets.

@sinfu
Created October 4, 2010 19:01
Show Gist options
  • Save sinfu/610238 to your computer and use it in GitHub Desktop.
Save sinfu/610238 to your computer and use it in GitHub Desktop.
metaArray
struct MetaArray(seq...)
{
alias seq Expand;
// CTFE-capable
bool opEquals(rhsSeq...)(MetaArray!rhsSeq )
{
return is(MetaArray!seq == MetaArray!rhsSeq);
}
}
template metaArray(seq...)
{
enum metaArray = MetaArray!seq(); // compile-time constant
}
enum a = metaArray!(int, "x", 100);
enum b = metaArray!(double, "y", 200);
static assert(a == a);
static assert(a != b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment