[C++] Function Template Parameter issue

Started by
1 comment, last by smc 16 years, 3 months ago
I have a template function that has a template class as a parameter. I am getting an error when trying to call this function


template <typename T>
void fill(TDArray<T>& da, T& ub, T& lb, int prec = 0) {
	
	for(int i = 0; i < da.size() ; i++) {
		da = generate(ub, lb, prec) ;
	}
}

// Calling code

TDArray<int> tda(10) ;

fill(tda, 100, 0, 0) ;


I receive the following error from gcc on OS-X:

error: no matching function for call to 'fill(TDArray<int>&, int, int, int)'


Not to sure what is going on here. Any pointers on what is going on?

∫Mc
Advertisement
Your function takes non-const references as parameters, and you try passing integer literals. You cannot bind a non-const reference to an integer literal like that. Try changing your function to take those parameters by value or const reference.
Thanks SiCrane. A bit of an oversight on my part. (Puts on dunce cap)
∫Mc

This topic is closed to new replies.

Advertisement