Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13-03-2010
Member
 
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.
Reply With Quote
  #2  
Old 13-03-2010
Member
 
Join Date: May 2008
Posts: 2,383
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.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #3  
Old 13-03-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
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;
Reply With Quote
  #4  
Old 13-03-2010
Member
 
Join Date: Feb 2008
Posts: 1,848
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
Reply With Quote
  #5  
Old 13-03-2010
Member
 
Join Date: Jan 2008
Posts: 1,515
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search



All times are GMT +5.5. The time now is 05:59 PM.