]> gcc.gnu.org Git - gcc.git/blob - libstdc++/stl/pair.h
Initial revision
[gcc.git] / libstdc++ / stl / pair.h
1 /*
2 *
3 * Copyright (c) 1994
4 * Hewlett-Packard Company
5 *
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation. Hewlett-Packard Company makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
13 *
14 *
15 * Copyright (c) 1996
16 * Silicon Graphics Computer Systems, Inc.
17 *
18 * Permission to use, copy, modify, distribute and sell this software
19 * and its documentation for any purpose is hereby granted without fee,
20 * provided that the above copyright notice appear in all copies and
21 * that both that copyright notice and this permission notice appear
22 * in supporting documentation. Silicon Graphics makes no
23 * representations about the suitability of this software for any
24 * purpose. It is provided "as is" without express or implied warranty.
25 */
26
27 #ifndef PAIR_H
28 #define PAIR_H
29
30 #include <stl_config.h>
31
32 template <class T1, class T2>
33 struct pair {
34 typedef T1 first_type;
35 typedef T2 second_type;
36
37 T1 first;
38 T2 second;
39 pair() : first(T1()), second(T2()) {}
40 pair(const T1& a, const T2& b) : first(a), second(b) {}
41
42 #ifdef __STL_MEMBER_TEMPLATES
43 template <class U1, class U2>
44 pair(const pair<U1, U2>& p) : first(p.first), second(p.second) {}
45 #endif
46 };
47
48 template <class T1, class T2>
49 inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) {
50 return x.first == y.first && x.second == y.second;
51 }
52
53 template <class T1, class T2>
54 inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) {
55 return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
56 }
57
58 template <class T1, class T2>
59 inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
60 return pair<T1, T2>(x, y);
61 }
62
63 #endif
This page took 0.039799 seconds and 5 git commands to generate.