Skip to content

Instantly share code, notes, and snippets.

@crazymonkyyy
Last active January 18, 2023 22:17
Show Gist options
  • Save crazymonkyyy/dd4361b5c258feec5e888f0e567aa478 to your computer and use it in GitHub Desktop.
Save crazymonkyyy/dd4361b5c258feec5e888f0e567aa478 to your computer and use it in GitHub Desktop.
//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