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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:27:56+00:00 2026-06-03T19:27:56+00:00

I have enabled unique_ptr in gcc 4.4.6 using the -std=c++0x option. It appears to

  • 0

I have enabled unique_ptr in gcc 4.4.6 using the -std=c++0x option. It appears to be working quite well and is exactly what I needed — a scoped pointer with a custom deleter.

However I did notice a problem.

typedef std::unique_ptr<X> XPtr;

XPtr ptr1(new X);
XPtr ptr2(new X);

std::cout << "ptr1 points to " << ptr1 << std::endl;
std::cout << "ptr2 points to " << ptr2 << std::endl;

displays:
ptr1 points to 1
ptr2 points to 1

I think the ostream inserter is inserting the bool value.

The following fixes it, but I’m wondering if this shouldn’t be part of the standard library.

template<typename Target, typename Deleter>
std::ostream & operator <<( std::ostream & out, const std::unique_ptr<Target, Deleter> & value)
{
    // output the raw pointer
    out << value.get();
    return out;
}

So the question is: is this a limitation of the current unique_ptr implementation in gcc, or am I expecting too much from unique_ptr?

  • 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-03T19:27:57+00:00Added an answer on June 3, 2026 at 7:27 pm

    This seems to be a bug in the library shipped with gcc 4.4.6. The conversion is

    explicit operator bool() const noexcept;
    

    and shouldn’t be triggered by trying to insert the pointer into an
    ostream. This should result in a compilation error and that is
    exactly what happens on gcc 4.7.

    Edit: gcc 4.4 did not support explicit conversion operators, hence this wasn’t working back then. You should get a newer gcc version to really use C++11.

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

Sidebar

Related Questions

I have enabled site-wide Django caching , but the third-party apps I am using
I have enabled google Minify in code igniter using this library on our website.
Please help regarding the following issue. I have enabled the Block popup option in
I have enabled the Web Server on my Mac OS X (10.5.6) by going
I have enabled the lighttpd mod_webdav module and set up a webdav mount point
I have enabled USB debugging on my phone and have set the Debuggable permission
I have enabled the static analyzer, but it is telling me that at the
I have a combobox that I have Enabled = false. When that is the
I have an Java application running in JBoss in which I have enabled JMX
I have installed WAMP and running PHP scripts on localhost. I have enabled cURL.

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.