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 8679589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:00:39+00:00 2026-06-12T21:00:39+00:00

In boost C++, a weak pointer is implemented as an observer to a shared

  • 0

In boost C++, a weak pointer is implemented as an observer to a shared (reference counted) pointer.

How are they implemented in objective-c, and why does this require runtime support? (ie besides having compiler support, iOS 5 or above is required to use weak references)

  • 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-06-12T21:00:41+00:00Added an answer on June 12, 2026 at 9:00 pm

    std::weak_ptr actually contains a pointer to a shared data-structure that holds book-keeping data and the referenced object. When the referenced object is destroyed this shared data is kept around so that weak_ptrs can see the book-keeping data that indicates the object is gone, and the weak_ptrs themselves don’t have to be modified when the referenced object is deallocated.

    In Objective-C weak references do not point to some intermediate object that holds book-keeping data. They are normal pointers that point either to the actual referenced object, or to nil if the referenced object is gone. Every __weak pointer has to be updated when some other part of the code releases the last non-weak pointer to an object. This requires runtime support.

    In other words, Obj-C weak pointers are normal pointers except that there’s compiler magic (which uses runtime support) working on them, whereas shared_ptrs and weak_ptrs are just wrappers that implement their own runtime support (in the smart pointers’ constructors, assignment operators, destructors, etc.) around pointers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does Boost, or anything else, contain a container will act like a shared pointer
I'm using boost's shared pointers, and enable_shared_from_this to enable returning a shared pointer to
shared_ptr is a reference counting smart pointer in the Boost library. The problem with
I am creating my own implementation of a weak/strong reference pointer relationship and I
Boost Network I am trying out this code in a small console app on
So, I use boost::shared_ptr for all the various reference-counting benefits it provides -- reference
Boost's C99 stdint implementation is awfully handy. One thing bugs me, though. They dump
Is there a simple, efficient weak/guarded pointer? I need multiple pointers to the same
I'm using Boost/shared_ptr pointers throughout my application. When the last reference to an object
boost::shared_polymorphic_downcast and the other boost::shared_ptr functions reside in <boost/shared_ptr.hpp> I recently enabled support for

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.