#Shared pointer in single-threaded application?

7 messages · Page 1 of 1 (latest)

wicked crest
#

Is there an alternative to std::shared_ptr without the thread-safety of the ref counting?

Background: when having, for example, a graph of 10k nodes that can point to each other in arbitrary ways in a single-threaded application, the use of std::shared_ptr seems to entail unnecessary overhead due to the thread safety.

maiden thicketBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

long marsh
#

the atomic counting is cheap

wicked crest
#

So there isn't an alternative in the standard library?

long marsh
#

built in? dont believe so, but you could make your own pretty simply or just copy paste from an existing implementation but remove the atomic part of the ref counting. but i seriously dont think you would see any worthwile performance benefits in removing that detail

wicked crest
#

ok, thank you!!

#

!solved