Reference Counting

R

Richard Herring

Protoman schrieb:
[ SmrtPtr said:
OK, I fixed the above, but, now I'm wondering: is SmrtPtr<T> safe to
use in a container, such as a linked list? Is it thread safe?

Depends on the container, if it can be used with it.

For the standard container classes, the values have to have
value-semantics. If your smart pointer works as it should, then its safe
to use in on of them.

For thread safety: Don't ask here, since C++ doesn't know about threads
(you should know this already)

OK, but how do I access this:

class Data
{
public:
Data():plus(new long double),mult(new long double),pow(new long
double){}
SmrtPtr<long double> plus;

Why? It appears to be a simple value class, so why do you have yet
another level of indirection just to access public data members?
SmrtPtr<long double> mult;
SmrtPtr<long double> pow;
};

SmrtPtr<Data> tuple(new Data);
//how do I access the members of tuple?
tuple->member
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top