bearophile wrote: > ted: > >> Could someone enlighten me ? > > This works: > > > import std.range: ElementType, isInputRange; > > ElementType!R testFunc(R, T)(R range, T foo) > if (is(ElementType!R == T)) { > static assert(isInputRange!R); > typeof(return) retVal = foo ^^ 2; // More DRY. > return retVal; > } > > void main() { > auto values = [0.0, 3.0, -1.0, 5.0]; > auto result = testFunc(values, 8.8); > } > > > The D compiler seems unable to compute ElementType!R in the > function signature. If I am right, then this seems worth an > enhancement request. > > Bye, > bearophile
thanks !... ... where you say 'More DRY' above, are you referring to - foo^^2 ( I just did foo*foo for the sake of the example), or - typeof(return) - a construct I am completely unfamiliar with and will now have to look up ! If it is 'typeof(return)' why would this be selected over ElementType!R ?? Is it more idiomatic ? regards, ted