Jump to content
  • Advertisement
Sign in to follow this  
smc

[C++] Function Template Parameter issue

This topic is 3846 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 = 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
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!