Confused by refusal to expand template

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Mar 23 15:52:40 PDT 2012


Code:
	struct S {
		int f(K)(K x) {
			return 1;
		}
		void func(K)(inout(K) x) {
			auto h = f(x);
		}
	}
	void main() {
		S s;
		s.func("abc");	// This is line 44
	}

This refuses to compile:

test2.d(44): Error: template test2.S.func(K) does not match any function template declaration
test2.d(44): Error: template test2.S.func(K) cannot deduce template function from argument types !()(string)

Removing 'inout' fixes the problem. But I don't understand why.


T

-- 
Perhaps the most widespread illusion is that if we were in power we would behave very differently from those who now hold it---when, in truth, in order to get power we would have to become very much like them. -- Unknown


More information about the Digitalmars-d-learn mailing list