Last active
January 18, 2023 22:17
-
-
Save crazymonkyyy/dd4361b5c258feec5e888f0e567aa478 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//aliasSeq shortened | |
alias Seq(TList...) = TList; | |
mixin template pullapartctinputs(){ | |
alias ints=Seq!(); | |
alias strings=Seq!(); | |
alias bools=Seq!(); | |
alias others=Seq!(); | |
static foreach(T;ctinputs){ | |
static if(is(typeof(T)==int)){ | |
ints=Seq!(ints,T); | |
} else { | |
static if(is(typeof(T)==string)){ | |
strings=Seq!(strings,T); | |
} else { | |
static if(is(typeof(T)==bool)){ | |
bools=Seq!(bools,T); | |
} else { | |
others=Seq!(others,T); | |
}}} | |
} | |
} | |
template pulloutints(ctinputs...)(){ | |
mixin pullapartctinputs; | |
int[] pulloutints(){ | |
return [ints]; | |
} | |
} | |
unittest{ | |
assert(pulloutints!()==[]); | |
assert(pulloutints!(1,2,3)==[1,2,3]); | |
assert(pulloutints!("hi",a=>a,1,2,3,false,true)==[1,2,3]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment