Nathan Merrill
Nathan Merrill

Reputation: 8386

How to return the pointer in a pointer in a pointer

I feel like this should be very easy, but I am unable to find an applicable question.

X is a shared_ptr<shared_ptr<Item> >.

I have a function that accepts a shared_ptr<Item>

How do I get that inner pointer? I can't just do X ->, and X->get() will return an Item*

Upvotes: 0

Views: 59

Answers (1)

Mike Seymour
Mike Seymour

Reputation: 254501

As with a normal pointer, you access a shared pointer's target by dereferencing it:

f(*X);

Upvotes: 3

Related Questions