Why doesn't std::pair have an allocator? 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?
Mark P wrote: Why doesn't std::pair have an allocator?
Because it doesn't allocate anything.
"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.
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?
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
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. ;-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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>...
|
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*>,...
|
by: hokus |
last post by:
How to code (generally) std::allocator class to use HeapAlloc function?
Thanks
|
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...
|
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:...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |