On Wed, Mar 30, 2016 at 08:43:03PM +0000, jmh530 via Digitalmars-d-learn wrote: > On Wednesday, 30 March 2016 at 18:56:29 UTC, H. S. Teoh wrote: > > > >Does this do what you want? > > > > Okay, I've looked at this a bit more thoroughly and it works perfectly > (perhaps with a better name put in phobos?). > > If I'm understanding this correctly, the ImplType creates the correct > type signature for the output and then conditionalOnly puts the right > value in.
Yes. It was a quick hack, though, and involves assigning the ranges to a local variable. There ought to be a way to pass the arguments directly, while substituting the non-ranges with only(x). But that would probably involve even more black magic that I'm already invoking. :-P It's pretty close to the point where I'd just throw up my hands and say, forget the template black magic shenanigans, just write a mixin and call it a day. > One thing that is confusing is that when I create a new function that > adjusts conditionalOnly to just return y instead of fun(y), then I get > an error about returning a tuple. I'm like, where did I use a tuple. I > guess related to https://issues.dlang.org/show_bug.cgi?id=15436 Yes... basically the compiler is complaining that it doesn't know how to return a value with of AliasSeq type. Why it can't do this, is a complex question that I don't have the time to get into right now... but basically, if you want to return it instead of calling the target function, you have to wrap it in a std.typecons.Tuple struct (how's that for confusing terminology?!), and use .expand to unwrap it when you need to pass it to a function. T -- Always remember that you are unique. Just like everybody else. -- despair.com