If we assume that
We can get some information from the
shared_ptr::use_count() function. §126.96.36.199.5 says:
long use_count() const noexcept;
Returns: the number of
*thisincluded, that share ownership with
use_count()is not necessarily efficient.—end note ]
At first sight the
long return type seems to answer the first question. However the note seems to imply that
shared_ptr is free to use any type of reference counting it wants to, including things like a list of references. If this were the case then theoretically there would be no maximum reference count (although there would certainly be a practical limit).
There is no other reference to limits on the number of references to the same object that I could find.
It's interesting to note that
use_count is documented to both not throw and (obviously) to report the count correctly; unless the implementation does use a
long member for the count I don't see how both of these can be theoretically guaranteed at all times.