473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

std::pair allocator?

Why doesn't std::pair have an allocator?
Jul 23 '05 #1
6 5915
"Mark P" <no*@my.real.email> wrote in message
news:NT****************@newssvr21.news.prodigy.com ...
Why doesn't std::pair have an allocator?


If it had one, how would it use it?
Jul 23 '05 #2
Mark P wrote:
Why doesn't std::pair have an allocator?


Because it doesn't allocate anything.
Jul 23 '05 #3

"Mark P" <no*@my.real.email> wrote in message
news:NT****************@newssvr21.news.prodigy.com ...
Why doesn't std::pair have an allocator?


A std::pair is not a container. Its purpose is not to allocate. Think of a
std::pair as a record-template for inserting or extracting a record-pair to
/ from a given associative container. Its the associative container that
handles or stores the allocation of a std::pair's contents.
Jul 23 '05 #4
Andrew Koenig wrote:
"Mark P" <no*@my.real.email> wrote in message
news:NT****************@newssvr21.news.prodigy.com ...

Why doesn't std::pair have an allocator?

If it had one, how would it use it?

I'm not sure :) I read on the SGI website, "A pair is much like a
Container, in that it 'owns' its elements." But I guess the concept of
an allocator only makes sense for containers which can grow in size or
contents, whereas any pair instance is of a fixed size?
Jul 23 '05 #5
Mark P wrote:
Andrew Koenig wrote:
"Mark P" <no*@my.real.email> wrote in message
news:NT****************@newssvr21.news.prodigy.com ...

Why doesn't std::pair have an allocator?


If it had one, how would it use it?

I'm not sure :) I read on the SGI website, "A pair is much like a
Container, in that it 'owns' its elements." But I guess the concept of
an allocator only makes sense for containers which can grow in size or
contents, whereas any pair instance is of a fixed size?


Right. Dynamic allocation isn't needed when the number of items
is known at compile time (though in other such cases it may be
desirable for other reasons, such as limited stack space).

-- James
Jul 23 '05 #6
Mark P wrote:
Andrew Koenig wrote:
"Mark P" <no*@my.real.email> wrote in message
news:NT****************@newssvr21.news.prodigy.com ...

Why doesn't std::pair have an allocator?

If it had one, how would it use it?

I'm not sure :) I read on the SGI website, "A pair is much like a
Container, in that it 'owns' its elements." But I guess the concept of
an allocator only makes sense for containers which can grow in size or
contents, whereas any pair instance is of a fixed size?


Basically, yes. allocators give containers a way to (surprise!) allocate
memory, but std::pair doesn't allocate memory. It's basically just
something like:

template <typename First, typename Second>
struct pair
{
First first;
Second second;
};

Not really much use for an allocator here. ;-)

Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Neil Zanella | last post by:
Hello, I would like to ask how come the design of C++ includes std::pair. First of all I don't think many programmers would use it. For starters, what the first and second members are depends...
0
by: ScOe | last post by:
I've made a container class over std::allocator. Also implement create, clear, push_back but i need some assistance on removing item from container. do i need to create empty container and than...
5
by: Eric Lilja | last post by:
As the subject says, which is the proper header to include for the type std::pair? In my program I have a std::vector of std::pair<std::string, std::string> and on my compiler including <vector>...
5
by: Vinu | last post by:
Hi I am facing a problem in compilation the error is like this In constructor xServices::CServices<TImp>::StHoldClientList::StHoldClientList(std::set<TImp*, std::less<TImp*>,...
1
by: hokus | last post by:
How to code (generally) std::allocator class to use HeapAlloc function? Thanks
7
by: Grahamo | last post by:
Hi, can anybody tell me where I can get the boiler plate code for std::allocator. I need to have my version of new and delete called and want to get reference code. My compilers headers are all...
1
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
18
by: desktop | last post by:
I have made this little test with std::pair: test<intt1(1); test<intt2(2); std::pair<test<int>,test<int mypair = std::make_pair(t1,t2); where test is a template class I wrote. It seems a bit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.