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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:39:43+00:00 2026-05-27T05:39:43+00:00

As I understand it, in the current specification of C++11, one should use: std::unique_ptr<>

  • 0

As I understand it, in the current specification of C++11, one should use:

  • std::unique_ptr<> for one owner (most of the time)
  • std::shared_ptr<> only when there are multiple owners in acyclic structure
  • std::weak_ptr<> sparingly only when there are cycles that need to be broken
  • A raw pointer as a handle to memory (no ownership) when a reference would not suffice

So my questions are:

  1. Are these policies sufficient or are there additional policies that
    I should be aware of?
  2. Are scoped_ptr<> and auto_ptr<> effectively obsolete?
  • 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-27T05:39:44+00:00Added an answer on May 27, 2026 at 5:39 am

    Are scoped_ptr<> and auto_ptr<> effectively obsolete?

    auto_ptr is deprecated in C++11, so there’s your answer. scoped_ptr doesn’t exist in C++11 and never did. The main reason to use boost::scoped_ptr is to ensure that ownership is never transferred (unless you cheat, of course). Then again, if you use unique_ptr, ownership can only be transferred if you use std::move or similar constructs. Or, as Howard points out, just make it a const std::unique_ptr.

    So it’s really up to you whether you want that extra bit of insurance. Also boost::scoped_ptr doesn’t have deleter support. So unique_ptr can play tricks that boost::scoped_ptr cannot.

    std::weak_ptr<> sparingly only when there are cycles that need to be broken

    I can’t say I agree with this policy necessarily. A weak_ptr should be used when an object may want to talk to something else, but it doesn’t own that something else. Which means that it can be deleted at any time, and the holder of the weak_ptr needs to be able to handle that deletion anytime it tries to talk to it.

    Breaking cycles is one of the uses of weak_ptr; it should not be the only time it is used.

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

Sidebar

Related Questions

I understand that .NET FileStream's Flush method only writes the current buffer to disk,
From what I understand document.cookie only gets your cookies for the current site you
If I understand this correctly: Current CPU developing companies like AMD and Intel have
My current solution will suck sometimes EDIT For those who don't understand,see this example:
I understand SetCurrentDirectory shouldn't be used in a multithreaded application since the current directory
From what I understand, due to the same origin policy enforcement in current browsers,
I understand how JS is run and I think I understand most of the
I don't understand how Current can be null and the LINQ function Last() can
I understand I can get current directory by $CurrentDir = Dir.pwd How about parent
Im struggling to understand the ViewModel part of the MVVM pattern . My current

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.