Skip to content

Instantly share code, notes, and snippets.

@JonathanILevi
Created April 9, 2020 00:34
Show Gist options
  • Save JonathanILevi/bf679315b4f60351f12f09a8b57524b4 to your computer and use it in GitHub Desktop.
Save JonathanILevi/bf679315b4f60351f12f09a8b57524b4 to your computer and use it in GitHub Desktop.
Template bug
import std;
void aFoo() {
}
void aBar() {
}
alias vsh1(string name) = (){};
template vsh1(alias foo) {
auto vsh1(Parameters!foo args) {
return;
}
}
alias vsh2(string name) = (){};
template vsh2(alias foo, alias bar) {
auto vsh2(Parameters!foo args) {
return;
}
}
void main() {
vsh1!"a"();
vsh2!"a"();
}
@adamdruppe
Copy link

template vsh2(T...) {
        static if(T.length == 1 && is(typeof(T[0]) == string))
                void vsh2() {}
        else static if(T.length == 2) {
                alias foo = T[0];
                alias bar = T[1];
                auto vsh2(Parameters!foo args) {
                        return;
                }
        } else static assert(0);
}

@JonathanILevi
Copy link
Author

JonathanILevi commented Apr 9, 2020

template vshCreate(T...)
if ((T.length==1 && is(typeof(T[0])==string)) || (T.length==2 && isCallable!(T[0]) && isCallable!(T[1]))
{
	static if (T.length==1) {
	}
	static if (T.length==2) {
	}
	static assert(false);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment