All Questions
Tagged with smart-pointer reference
3 questions
3
votes
1
answer
3k
views
C++ API design: using references vs smart pointers in a getter API
I'm trying to design an API for an object manager that registers and retrieves different related objects. When I want to retrieve an object, I can query it by its object id. I'm wondering if I should ...
1
vote
0
answers
217
views
Managing reference-like members with shared pointers [closed]
It is a well-known fact that there is no built-in mechanism that prevents member fields that are references from being invalidated, even if they are const. (For more background see: https://herbsutter....
10
votes
3
answers
7k
views
Polymorphic template container: shared_ptr vs reference_wrapper
Assuming we have two classes:
class A
{
...
}
class B : public A
{
...
}
Would it be better to write
std::deque<shared_ptr<A> > container;
or
std::deque<reference_wrapper<...