Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 672675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:30:38+00:00 2026-05-14T00:30:38+00:00

For the past few years, I’ve generally accepted that if I am going to

  • 0

For the past few years, I’ve generally accepted that

if I am going to use ref-counted smart pointers

invasive smart pointers is the way to go

—

However, I’m starting to like non-invasive smart pointers due to the following:

  1. I only use smart pointers (so no Foo* lying around, only Ptr)
  2. I’m starting to build custom allocators for each class. (So Foo would overload operator new).
  3. Now, if Foo has a list of all Ptr (as it easily can with non-invasive smart pointers).
  4. Then, I can avoid memory fragmentation issues since class Foo move the objects around (and just update the corresponding Ptr).

The only reason why this Foo moving objects around in non-invasive smart pointers being easier than invasive smart pointers is:

In non-invasive smart pointers, there is only one pointer that points to each Foo.

In invasive smart pointers, I have no idea how many objects point to each Foo.

Now, the only cost of non-invasive smart pointers … is the double indirection. [Perhaps this screws up the caches].

Does anyone have a good study of expensive this extra layer of indirection is?

EDIT: by smart pointers, I may be referring to what others call “shared-pointers”; the whole idea is: there is a reference-count attached to objects, and when it hits 0, the object is automatically deleted

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:30:38+00:00Added an answer on May 14, 2026 at 12:30 am

    There are several important difference between invasive or non-invasive pointers:

    The biggest advantage of second (non-invasive):

    • It is much simpler to implement weak reference to second one (i.e. shared_ptr/weak_ptr).

    Advantage of first is when you need to get smart pointer on this (at least in case of boost::shared_ptr, std::tr1::shared_ptr)

    • You can’t use shared_ptr from this in constructor and destructor.
    • It is quite non-trivial to have shared_from this in the hierarchy of classes.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am aware that there were similar questions in past few years, but after
In the past few years of using svn, I've frequently run into problems where
Over the past few years I've been on projects where we've run into a
For the past few years I have been using Gary Keith's browscap file to
I have been following the usage of JavaScript for the past few years, and
There have been several questions over the past few days about the proper use
Through the past few years I've been busy with server side programming and I
For the past few years I've continuously struggled with unit testing database code and
In the past few years I've mostly done UI development in Eclipse, which is
For the past few years, I've been developing sites with Eric Meyer's CSS resets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.