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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:42:21+00:00 2026-05-31T03:42:21+00:00

Nicolai Josuttis, in his book The C++ Standard Library – A Tutorial and Reference,

  • 0

Nicolai Josuttis, in his book “The C++ Standard Library – A Tutorial and Reference”, writes, at page 44, the following paragraph :

According to the concept of auto_ptrs, it is possible to transfer ownership into a function by using a constant reference. This is very dangerous because people usually expect that an object won’t get modified when you pass it as a constant reference. Fortunately, there was a late design decision that made auto_ptrs less dangerous. By some tricky implementation techniques, transfer of ownership is not possible with constant references. In fact, you can’t change the ownership of any constant auto_ptr: …

If is not possible to change ownership with a constant reference, why the expressions “This is very dangerous” and “less dangerous” above ?

  • 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-31T03:42:23+00:00Added an answer on May 31, 2026 at 3:42 am

    Summing up comments:

    “This is very dangerous” refers to when std::auto_ptr<>‘s copy constructor (which transfers ownership) took a const reference argument – this is a complete violation of const-correctness.

    “Less dangerous” refers to the fact that the copy constructor (which now takes a non-const reference) can transfer ownership at all; this is still dangerous, just not as dangerous as when the copy constructor took a const reference.

    This aspect of std::auto_ptr<> is universally considered a flaw in the class, to the extent that it’s generally considered unusably broken. Consequently, boost::scoped_ptr<> and boost::shared_ptr<> are largely considered the “real” smart pointers of C++03, and in C++11 std::auto_ptr<> is deprecated altogether in favor of std::unique_ptr<> (and removed entirely in C++17).


    Update: As of Boost 1.57, the Boost.Move library now supplies a C++03 emulation of std::unique_ptr<> which should be used rather than boost::scoped_ptr<>: boost::movelib::unique_ptr<>.

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

Sidebar

Related Questions

I'm reading through: The C++ Standard Library: A Tutorial and Reference by Nicolai M.
I'm reading: The standard C++ Library: A Tutorial and Reference by Nicolai M. Jossuttis
I am reading Nicolai Josuttis book on C++STL algorithms. For many algorithms such as
I have a list of input type=file with their names as list[] . Following
I try to compile the following code example from C++ Templates - The Complete
i am trying to parse the following code, but the javascript fails me ..
I have the following YAML: - name: List of monkeys - author: Nicolas Raoul
After reading a few related questions I've decided to use the tpl library to
I have a list of standard names standard = [Richard,Robert,Nicolas] and a dictionary of
I have the 3 following tables in a MySQL 4.x DB : hosts: (300.000

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.