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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:42:27+00:00 2026-06-04T18:42:27+00:00

I understand how auto_ptr works in C++03. It is based on this trick. The

  • 0

I understand how auto_ptr works in C++03. It is based on this trick. The trick uses a user-defined conversion to steal the pointer from one object to another when code such as this auto_int p(auto_int(new int())); is written. However, I’ve several questions in this regard.

  1. Why isn’t the compiler-generated copy-ctor called?
  2. Why does the user-defined conversion take precedence over a compiler-generated copy-ctor?
  3. Is there a compiler-generated copy-ctor to begin with?
  4. If not, what language rule suppresses it?
  • 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-04T18:42:29+00:00Added an answer on June 4, 2026 at 6:42 pm

    Why isn’t the compiler-generated copy-ctor called?

    Because the class already supplied a copy-constructor, a mutable one which is still valid, so the compiler does not generate a default one.

    Why does the user-defined conversion take precedence over a compiler-generated copy-ctor?

    There is no compiler generated copy-constructor.

    Is there a compiler-generated copy-ctor to begin with?

    Finally! Nope, there isn’t.

    If not, what language rule suppresses it?

    It’s 12.8.2:

    A non-template constructor for class X is a copy constructor if its first parameter is of type X&, const X&, volatile X& or const volatile X&, and either there are no other parameters or else all other parameters have default arguments.

    And 12.8.4:

    If the class definition does not explicitly declare a copy constructor, one is declared implicitly.

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

Sidebar

Related Questions

Declarations of auto_ptr from C++ Standard Library namespace std { template <class Y> struct
What I want to do is this: #include <memory> class autostr : public std::auto_ptr<char>
I cant understand why in the class constructor I can call this function but
I just try to understand the concept of the ItemsPanelTemplate. For this i built
I don't really understand what's going on here. This is my css and html
I can't understand the reason of this trouble: I'm using image slider and everything
It's probably easiest to understand by looking at this fiddle: http://jsfiddle.net/TdBdW/1/ - apologies for
I've recently come across this rant . I don't quite understand a few of
I was going through the auto_ptr documentation on this link auto_ptr There is something
As I understand it, in the current specification of C++11, one should use: std::unique_ptr<>

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.