On Sunday, 21 June 2015 at 10:06:15 UTC, biozic wrote:
You can use a template alias parameter with a default value
that is your default lambda:
int indexOfMax(alias fun = a => a, R)(R range)
{
// Use `fun` here like a function.
}
-- Nico
Thanks a lot, it works !!
On Sunday, 21 June 2015 at 09:34:51 UTC, kerdemdemir wrote:
Hi,
I need to find the index of maximum element so my code:
int indexOfMax(R)(R range)
{
alias Type = typeof(range.front().re); > I don't like
.re here
Type max = 0;
size_t maxIndex = 0;
foreach ( index,el
Hi,
I need to find the index of maximum element so my code:
int indexOfMax(R)(R range)
{
alias Type = typeof(range.front().re); > I don't like
.re here
Type max = 0;
size_t maxIndex = 0;
foreach ( index,elem; range )
{
if ( elem.re > max )-> And