Sign in to follow this  

[C++] Function Template Parameter issue

This topic is 3632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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[i] = 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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this