2 ms·
It doesn't modify anything inside the shared_ptr itself, but a refcount which is pointed to by a pointer field in the shared_ptr. So you can say foo(shared_p
by tlb 7y ago
It doesn't modify anything inside the shared_ptr itself, but a refcount which is pointed to by a pointer field in the shared_ptr. So you can say
foo(shared_ptr<T> const &x) {
saved_x = x;
}
and it'll update the refcount exactly once when doing the assignment.
- mark-r 7y agoThat's the problem with modern C++, you can't reason about it on general principles - you have to know way too much about implementation detail.