Which is the proper header to include for std::pair?

E

Eric Lilja

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> and <string> also gives
me access to std::pair. I just want to know so I don't have to muck about
with the includes when porting to a different compiler.

/ Eric
 
M

Matthias Kaeppler

Eric said:
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> and <string> also gives
me access to std::pair. I just want to know so I don't have to muck about
with the includes when porting to a different compiler.

/ Eric

This is almost certainly implementation specific. I didn't find any
words in the standard where std::pair has to be defined.
Better ask in the newsgroup specific for your STL platform.
 
P

Pete Becker

Eric said:
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> and <string> also gives
me access to std::pair. I just want to know so I don't have to muck about
with the includes when porting to a different compiler.

std::pair is defined when you include <utility>.
 
V

Victor Bazarov

Matthias said:
This is almost certainly implementation specific.
Not.

I didn't find any
words in the standard where std::pair has to be defined.
Better ask in the newsgroup specific for your STL platform.

Eric, use <utility>

Matthias, get better glasses or something. 20.2.2.

V
 
M

Matthias Kaeppler

Victor said:
Eric, use <utility>

Matthias, get better glasses or something. 20.2.2.

V

Sorry.
This happens if you search for "pair" and fail to realize where you
landed (that is, in the "Utility components" section). My bad.
Maybe I should get better glasses afterall ;)
 
E

Eric Lilja

Pete Becker said:
std::pair is defined when you include <utility>.

Thank you Pete and the others who replied to my inquiry. I will add an
#include <utility> statement in order to make my code as portable to other
implementations of the standard library as possible.

/ Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top