Results 1 to 5 of 5

Thread: How to use the get_allocator() : C++

  1. #1
    Join Date
    Jan 2010
    Posts
    26

    How to use the get_allocator() : C++

    I an interested in doing the C++ language programming. I had learned the C++ language in the BSC-IT. I can know the actual concept or working of the C++ functions. So, I want to know what is the get_allocator() function of the C++ language. I also want to know how to the use of the get_allocator() function in the C++ programming. Can anyone knows about the get_allocator() function of C++ language.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: How to use the get_allocator() : C++

    The get_allocator() function can be used to get an allocator in the C++ language. The get_allocator() function that can returns the allocator of an object that can be used to construct the vector. The get_allocator() function can be comes under the vector class. The get_allocator() function can be the one of the function of the vector class. i hope this information can be sufficient for you.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to use the get_allocator() : C++

    The get_allocator() function of the C++ language can returns an allocator of the given specified vector. The member type allocator_type can be specified to the same as the parameter of the second template can be used to instantiate that specific class vector and its type of an allocator. The following can be the syntax of the get_allocator() function of the C++ language :
    Code:
    allocator_type get_allocator() const;

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to use the get_allocator() : C++

    The following can be an example that can uses the get_allocator() function of the C++ language to illustrate the get_allocator() function :
    Code:
    #include <iostream>
    #include <vector>
    using namesqace std;
    int main ()
    {
      vector<int> mvctr;
      int * q;
      unsigned int i;
      q=mvctr.get_allocator().allocate(5);
      for (i=0; i<5; i++) q[i]=i;
      cout << "The allocated array contains:";
      for (i=0; i<5; i++) cout << " " << q[i];
      cout << endl;
      mvctr.get_allocator().deallocate(q,5);
      return 0;
    }
    Outqut:
    Code:
    The allocated array contains: 0 1 2 3 4

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to use the get_allocator() : C++

    The get_allocator() function of the C++ language can be used to return a copy of an object of the allocator that can be used to construct the vector. The get_allocator() function can be used by the vector to get the particular allocator. The Allocators for the class vector can describes how the class can manages the storage. The default allocators that can be supplied with the containers of the STL classes can be sufficient for the most of the programming requirements.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,064,791.12607 seconds with 15 queries