unordered_set get_allocator() in C++

get_allocator(): This function is available in the File: unordered_set.h. This function is a build-in function in STL of C++.

Syntax:

std::allocator<int> std::unordered_set<int>::get_allocator() const

This functions returns the allocator object used by the unordered_set.

Parameters: NA

File: unordered_set.h

Returns : The member function returns the stored allocator object.

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    unordered_set<intst = {4681225};

    unordered_set<int>::allocator_type type = st.get_allocator();

    int x = 4;
    cout << "Address is " << type.address(x<< "\n";

    cout << "Maximum size is " << type.max_size() << "\n";

    return 0;
}


Output:

Address is 0x61fda8 Maximum size is 4611686018427387903


No comments:

Post a Comment