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

  • Home
  • SEARCH
  • 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 6000841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:45:06+00:00 2026-05-23T00:45:06+00:00

Howard Hinnant explained that unique_ptr can also use a custom storage type . He

  • 0

Howard Hinnant explained that unique_ptr can also use a custom storage type. He mentions as an example “shared memory“.

He only gives the rough idea (which is fine for a quick intro). But can anyone complete his example for a “custom storage type” (be it shared memory or not)?

To support placing unique_ptr into shared memory, the custom deleter can contain a custom pointer type (typically not a real pointer in shared memory applications). One simply places a nested type called pointer which emulates pointer behavior within your deleter, publicly accessible:

template <class T>
class MyDeleter
{
public:
    class pointer
    {
     public:
        friend bool operator==(pointer x, pointer y);
        friend bool operator!=(pointer x, pointer y);
        // ...
    };

    void operator()(pointer p);
};

void test()
{
    unique_ptr<int, MyDeleter<int> > p;
    MyDeleter<int>::pointer p2 = p.get();  // A custom pointer type used for storage
}

I suspect that // ... must be extended, and test() will probably do some additional things in a real “custom storage type” example.

Can someone tell me where he/she

  • has actually already used this customization,
  • and in that context,
  • which what customization code, (at //... probably)
  • and how client code uses it? (at test() probably)
  • 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-23T00:45:07+00:00Added an answer on May 23, 2026 at 12:45 am

    You might be interested in boost::offset_ptr which served as the motivating use case for this customization point in unique_ptr. offset_ptr is a fully developed pointer type which could be installed into a custom deleter using a simple typedef. Its use case is to put unique_ptr into shared memory.

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

Sidebar

Related Questions

Borrowing Howard Hinnant's example and modifying it to use copy-and-swap, is this op= thread-safe?
I'm currently trying to use Howard Hinnant's unique_ptr implementation , and am running into
I have a class that is using boost::aligned storage to statically allocate memory within
There is a Java Struts application running on Tomcat, that have some memory errors.
I'm trying to set up an application that includes groups that can be composed
I came upon the Curry-Howard Isomorphism relatively late in my programming life, and perhaps
I'm trying to produce a clipping area in a UIView that's generated from path
I'm a RDBMS guy that has a project that I believe will work really
Since we can query on the XML file from C# (.NET), why do we
I am reading source code of hoard memory allocator, and in the file of

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.