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

  • Home
  • SEARCH
  • 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 3335508
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:01:35+00:00 2026-05-18T00:01:35+00:00

Aside from catching the bad_weak_ptr error thrown when trying to call shared_from_this() on a

  • 0

Aside from catching the bad_weak_ptr error thrown when trying to call shared_from_this() on a pointer that is a raw pointer, is there a way of testing whether or not the object is being reference counted?

I have functions that deal with the raw pointer and shared pointer and I want to be sure that the error is obvious when using the wrong one? I can of course just catch the error, but I just wondered if there’s an easy way of testing for this particular case?

  • 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-18T00:01:35+00:00Added an answer on May 18, 2026 at 12:01 am

    A call to std::enable_shared_from_this<T>::shared_from_this() will never fail for an existing valid object, or pointer to it. EDIT: … if there is at least one instance of std::shared_ptr<YourClass> where YourClass is std::enable_shared_from_this<YourClass>. This is a stricter statement than the first one and I apologize if it was misunderstood.

    You assure the validity of shared_from_this() by creating only shared_ptr instances of your classes. There is no way to check if a YourClass instance is managed by a shared_ptr, except of catching the exception.

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

Sidebar

Related Questions

Aside from trying perldoc <module name> individually for any CPAN module that takes my
Aside from DeployerFTP, are there any plugins that offer the ability to deploy a
Aside from writing an alias or script, is there a shorter command for getting
Aside from Episerver.com What other websites do people who develop using EPiServer use as
Aside from executing XP_CmdShell, which I have disabled in my SQL 2005 installation, what
Aside from enhanced user experience, do Ajax calls provide any significant performance benefit?
Do you use code-generation tools (aside from those used to generate proxies and from
I'm looking at opening up a website in the near future and aside from
This is in reference to a question I asked earlier. Aside from viewing the
Which Eclipse files is it appropriate to put under source control, aside from the

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.