From: Daniel on
I found a sample for using vectors: Could someone explain to me what the
allocator is in the following sample:

// Create a vector v3 with 3 elements of value 1 and with the allocator

// of vector v2

vector <int> v3( 3, 1, v2.get_allocator( ) );




From: Igor Tandetnik on
"Daniel" <Mahonri(a)cableone.net> wrote in message
news:eLFKWjNpIHA.3652(a)TK2MSFTNGP03.phx.gbl
> I found a sample for using vectors: Could someone explain to me what
> the allocator is in the following sample:

I assume you have read the documentation and found it lacking. Is there
a specific question you can't find an answer for?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


From: Daniel on
I don't have a specific question about this one. I just saw the example and
wondered what it meant. I'm more concerned about my other questions.

Daniel

"Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message
news:ueXKw9NpIHA.2068(a)TK2MSFTNGP05.phx.gbl...
> "Daniel" <Mahonri(a)cableone.net> wrote in message
> news:eLFKWjNpIHA.3652(a)TK2MSFTNGP03.phx.gbl
>> I found a sample for using vectors: Could someone explain to me what
>> the allocator is in the following sample:
>
> I assume you have read the documentation and found it lacking. Is there a
> specific question you can't find an answer for?
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>


From: Bo Persson on
Daniel wrote:
> I found a sample for using vectors: Could someone explain to me
> what the allocator is in the following sample:
>
> // Create a vector v3 with 3 elements of value 1 and with the
> allocator
> // of vector v2
>
> vector <int> v3( 3, 1, v2.get_allocator( ) );

The allocator is an object that allocates memory. :-)

Most of the containers have this as a point of customization - if you
don't want that default standard allocator (std::allocator), you can
pass another one to the constructor.

In this case it doesn't make much sense, as vector<int> must use a
std::allocator. If it was vector<int, special_allocator>, the code
would be more reasonable.


Bo Persson