0

Suppose I have a shared pointer to some data structure:

struct Data {
    int a;
    int b;
};
shared_ptr<Data> data = make_shared<Data>();

Is it possible to obtain a shared_ptr<int> to data->b which reuses the ref-count of data.

I.e. I want to pass a shared pointer to only a part of a reference-counted structure.

Tali
  • 861
  • 8
  • 17

0 Answers0