cannot deduce template lambda from argument
aliak
something at something.com
Wed Dec 6 14:40:31 UTC 2017
On Wednesday, 6 December 2017 at 11:02:01 UTC, Jonathan M Davis
wrote:
> If you only want one type, then given n that type; I'm pretty
> sure that it would be
>
> alias lambda = (int n) => n * n;
>
> if you wanted an int. But if you want to do anything more
> complicated with it, it would make more sense to just turn it
> into a proper function template.
>
> - Jonathan M Davis
Roight, I was more thinking along the lines of a little more
complicated I guess :)
i.e.:
template lambda(T)
if (isIntegral!T)
{
alias lambda = (T n) => n * n;
}
But you're right, if it gets more complicated a proper function
is probably better. Plus I just tried and it seems like you can't
really constrain a variable template anyway. Unless there's some
magic syntax I've overlooked in the docs.
Thanks!
Thanks!
More information about the Digitalmars-d-learn
mailing list