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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:09:03+00:00 2026-06-15T04:09:03+00:00

My project is in c++11, using vs2012. Right now I don’t feel the need

  • 0

My project is in c++11, using vs2012.
Right now I don’t feel the need of using custom memory management but, what arrangements should I take in order to facilitate an eventual future modification?

I thought of using a macro for “new”/”new[]”/”delete”/”delete[]” and typedefs for containers and smart pointers.

What are the best practises?

  • 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-15T04:09:04+00:00Added an answer on June 15, 2026 at 4:09 am

    From my point of view, all you have to do is basically decide on a certain convention that you will use throughout your implementation. A good template for making your architecture allocator aware is to look on how this is achieved for the STL containers and try to design you data structures like them. If you look for example on the std::vector interface the second parameter to this container is always the Allocator type. The Allocator has to follow a certain interface that will allow easy replacing of the default allocator implementation by a custom one.

    But coming back to code that you write: In a project that I work on we defined it like follows. For an object that is supposed to consume large amounts of memory we define a templated super class that allows to specify a custom allocator.

    template<class AllocatedClass, typename Allocator=std::allocator<AllocatedClass>
    class AbstractMyClass {
    public:
     static void *operator new(size_t sz){ /*...*/ }
     static void operator delete(void *p){ /*...*/ }
    };
    

    Now, if you define a subclass of this you would:

    class MyClass : public AbstractMyClass<MyClass> {
    };
    

    Thus the new object MyClass will use the specified allocator of the parent class. If you now implement you own allocator you can simply replace either the default template parameter in the super class or you can specify it explicitly in your sub-class.

    Using this approach you are more or less safe in using a custom allocator at a later point in time.

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

Sidebar

Related Questions

I am using VS2012 and my project is 4.0, but I want to use
I'm having trouble using python imports in VS2012. I can't get the project to
Right now I am writing a little c++ console program using VS2010 Express. The
I'm trying to use the g2log logging library inside my DLL project using VS2012.
The project that I've been working on involves porting some old code. Right now
I am using VS2010 to create a new unit test project to test my
I was happily using VS2010 Premium version for a C/C++ coding project, and needed
I have just created a new project in VS2010 using the Visual c# >
I have a VS2010 unit test project set to using SpecFlow 1.8.1 and mstest.
I just created a simple project in VS2010, C# dotnet 3.5 using System; using

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.