Javatpoint Logo
Javatpoint Logo

C++ set get_allocator()

C++ set get_allocator() function is used to return the copy of allocator object which helps to construct the set container.

Syntax

Parameter

None

Return value

Returns an allocator associated with set container.

Complexity

Constant.

Iterator validity

No changes.

Data Races

The container is accessed.

Concurrently accessing the elements of set is safe.

Exception Safety

This function never throws exceptions.

Example 1

Let's see the simple example:

Output:

Allocated size = 32

Example 2

Let's see a simple example:

Output:

The allocated array contains: 10 20 30 40 50

Example 3

Let's see a simple example to check whether the allocators are interchangeable or not:

Output:

The number of integers that can be allocated
before free memory is exhausted: 461168601842738790.

The number of doubles that can be allocated
before free memory is exhausted: 461168601842738790.

The allocators are interchangeable.

Example 4

Let's see a simple example:

Output:

42, 43

Next TopicSet operator==





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA