Data for an object in dispensers?

What is "data at the facility in dispensers". I donโ€™t seem to understand what this means. Does anyone have a good explanation or reference to what this means in terms of C ++?


EXPLANATION

Section 19.4.2 "C ++ Programming Language (Special Edition)" p. 573

โ€œSimilarly, if the dispensers were allowed to be completely general, the rewrite mechanism that allows the dispenser to distribute elements of arbitrary types should be more complex. Therefore, it is assumed that the standard dispenser does not contain data for each object and the implementation of this standard container can take advantage of this.โ€

+4
source share
2 answers

Object data or local state refers to any non-static data elements in the dispenser class.

The problem is that currently (in c++03 ) there is no support for distributors with the so-called local state. This is often considered a drawback of the dispenser model in modern c++ .

Read this article that details the design of the custom valve. The paragraph in the Design section addresses some of the trap issues that include the local state.

In short, some operations in the standard library currently require objects of a certain type to be reliably distributed by one instance of the allocator and freed by another instance of the allocator (both allocators of the same type - of course!). This could be, for example, when implementing list::splice . If the dispensers are allowed to have a local state, this can become complicated ...

In the upcoming c++0x version, it looks like distributors will be allowed to enable local state, see the scope section section> here .

Hope this helps.

+5
source

It just means that std::allocator<T> does not contain data elements for each instance ... basically it is a wrapper around the functions of allocating and freeing memory, and it also contains definitions of certain required typedefs, as well as mechanisms to restore an existing allocator to he could highlight types that were not part of the original instance of the distributor pattern. Thus, basically what is being claimed is that if there were actual private data members that needed to be managed, especially in light of the requirement that the STL dispenser allow reordering, this could greatly complicate the implementation of the generator dispenser depending on what these submitted data are for each instance.

+1
source

All Articles