Using map result type
AA
duser at fastmail.com
Sun Dec 8 01:10:21 UTC 2019
I'd like to accept the return type of map. From some previous
questions that I should accept a template?
So for something like:
```
void mapAccepter(Range)(Range r)
{
import std.array : array;
import std.stdio : writeln;
auto collected = r.array;
writeln(collected);
}
void main()
{
import std.algorithm.iteration : map;
int[] nums = [1, 2, 3];
auto evenness = map!(n => n % 2 == 0)(nums);
mapAccepter(evenness);
}
```
1) Is there any way I can make `mapAccepter` not a templated
function?
2) Is there any way if I need to make `mapAccepter` templated to
constrain Range to be a range of booleans.
More information about the Digitalmars-d-learn
mailing list