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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:08:34+00:00 2026-06-12T22:08:34+00:00

A member of my class is a boost::scoped_ptr which is set to (T*)0 when

  • 0

A member of my class is a boost::scoped_ptr which is set to (T*)0 when the object is created. The class has an init() method that actually initializes the smart pointer with a new object.

However, if an exception is thrown before that smart pointer has a valid reference, it very un-smartly tries to delete null (release) or it asserts (debug).

How do I get it to ignore null pointers upon destruction without modifying the original source code; and, if that isn’t possible, is there a more suitable alternate smart pointer class to use instead?

  • 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-12T22:08:35+00:00Added an answer on June 12, 2026 at 10:08 pm

    boost::scoped_ptr actually ignores null pointers in its destructor. boost::scoped_ptr uses boost::checked_delete() for deletion. boost::checked_delete() uses plain delete in order to delete (boost::checked_delete() also checks so that T is not incomplete).

    And you are allowed to delete null pointers with delete (unlike free()). Are you sure that the error is really in boost::scoped_ptr ?

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

Sidebar

Related Questions

i have a class that has this function: typedef boost::shared_ptr<PrimShapeBase> sp_PrimShapeBase; class Control{ public:
I'm using an object to start boost thread and it has some public member
Class member var named id below is of type int. Need to set from
C++0x thread library or Boost.thread define non-member variadic template function that lock all lock
I have a class Yarl in my code with a member function refresh that
I'm trying to use SFINAE to detect if a class has an overloaded member
I have class foo that contains a std::auto_ptr member that I would like to
I am trying to cerate my own class with boost::adjacency_matrix graph as a member,
When using boost::scoped_ptr to hold a reference, the destructor of the derived object is
i am using boost mutex in MessageQueue class as a private member in 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.