• Advertisement
Sign in to follow this  

Smart pointer question

This topic is 3703 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

Let's say I have the following:
const boost::shared_ptr<int> x;
What's const? The smart pointer itself, or the data it's pointing to? And what about this:
boost::shared_ptr<const int> x;

Share this post


Link to post
Share on other sites
Advertisement
1: The smart pointer itself. 2: The data it's pointing to.

Share this post


Link to post
Share on other sites
It's exactly what it looks like, if you read < as "to" and > as "".

a const smart pointer to an int; a smart pointer to a const int.

Share this post


Link to post
Share on other sites
Well, the confusion came from regular pointer syntax:

const int* x

Means that the the data pointed to by x is const, not x itself.

Share this post


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

  • Advertisement