Strange casting error when using lamdas

Robert M. Münch robert.muench at saphirion.com
Thu Dec 5 15:25:20 UTC 2019


On 2019-12-04 19:23:07 +0000, Steven Schveighoffer said:

> Is one a delegate and one a function pointer? This can easily happen 
> for untyped lambdas.

Not sure if the code-snippets already give an explanation but the 
differences I have are:

1. Working case

template filter(alias pred)
{
	auto filter(TObservable)(auto ref TObservable observable)
	{
        	static struct FilterObservable
        	{
				...
			}

			return FilterObservable(observable);
	}
}

2. Non-Working case

template filter(alias pred)
{
    auto filter(TObservable)(auto ref TObservable observable)
    {
        return FilterObservable!(pred, TObservable)(observable);
    }
}

struct FilterObservable(alias pred, TObservable)
{
	...
}

The constructor has the same implementaion in both cases.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list