Jump to content
  • Advertisement
Sign in to follow this  

templates and const

This topic is 4808 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'm confused about how templates deal with 'const', and I can't find any literatur on it. Inside a template class, if the return type of a method is const T* and T = int then the actual return type is int* const or T = int* then the actual return type is int* const* Or declaring a vector: vector<const int> r; You would expect r[0] = 1 to cause a compiler error...but it doesn't - but vector<const int*> r; *r[0] = 3; does cause a compiler error. Can anyone shed some light on this, or point me in the right direction?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!