What is the purpose and use of `memory_resource`?

Standard C++17 includes the new pmr namespace, which includes a set of classes grouped under the name memory_resource .

After searching the Internet, I found very little vulgarized information about this, a direct consequence of this question is:

What are the main ideas of pmr and especially pmr::memory_resource ?


Specializing a little more, some question marks in my head:

  • What will it bring new, or what were the restrictions that it allows?
  • What is the difference with allocator ?
  • Does polymorphism mean that you can choose the allocator runtime provided to the container constructor? (e.g. for testing purposes)
  • Does this help implement a memory pool or other memory management schemes?

Context:

In order to create a memory pool allocator, I found information about this namespace. Reading names like pool_options or polymorphic_allocator got my attention.


Related questions:

polymorphic_allocator: when and why should I use it?

NOTE. Related questions do not imply any implicit duplication requirement.

+8
c ++ allocator c ++ 17
source share

No one has answered this question yet.

See similar questions:

thirty
polymorphic_allocator: when and why use it?

or similar:

8499
What is the "->" operator in C ++?
3076
What are the differences between a pointer variable and a reference variable in C ++?
2387
What does an explicit keyword mean?
2101
What is the difference between #include <filename> and #include "filename"?
1994
What are the basic rules and idioms for operator overloading?
1911
What is the rule of three?
1717
What is the idiom of copy and swap?
1564
What is semantics of movement?
1391
What is a lambda expression in C ++ 11?
786
What are the new features in C ++ 17?

All Articles