1 // TR1 utility -*- C++ -*-
3 // Copyright (C) 2004, 2005, 2006, 2007, 2008. 2009, 2010, 2011
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
27 * This is a TR1 C++ Library header.
30 #ifndef _GLIBCXX_TR1_UTILITY
31 #define _GLIBCXX_TR1_UTILITY 1
33 #pragma GCC system_header
35 #include <bits/c++config.h>
36 #include <bits/stl_relops.h>
37 #include <bits/stl_pair.h>
39 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
48 template<int _Int, class _Tp>
51 // Various functions which give std::pair a tuple-like interface.
52 template<class _Tp1, class _Tp2>
53 struct tuple_size<std::pair<_Tp1, _Tp2> >
54 { static const int value = 2; };
56 template<class _Tp1, class _Tp2>
58 tuple_size<std::pair<_Tp1, _Tp2> >::value;
60 template<class _Tp1, class _Tp2>
61 struct tuple_element<0, std::pair<_Tp1, _Tp2> >
62 { typedef _Tp1 type; };
64 template<class _Tp1, class _Tp2>
65 struct tuple_element<1, std::pair<_Tp1, _Tp2> >
66 { typedef _Tp2 type; };
74 template<typename _Tp1, typename _Tp2>
75 static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
76 { return __pair.first; }
78 template<typename _Tp1, typename _Tp2>
79 static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
80 { return __pair.first; }
86 template<typename _Tp1, typename _Tp2>
87 static _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair)
88 { return __pair.second; }
90 template<typename _Tp1, typename _Tp2>
91 static const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
92 { return __pair.second; }
95 template<int _Int, class _Tp1, class _Tp2>
96 inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
97 get(std::pair<_Tp1, _Tp2>& __in)
98 { return __pair_get<_Int>::__get(__in); }
100 template<int _Int, class _Tp1, class _Tp2>
101 inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
102 get(const std::pair<_Tp1, _Tp2>& __in)
103 { return __pair_get<_Int>::__const_get(__in); }
105 _GLIBCXX_END_NAMESPACE_VERSION
109 #endif // _GLIBCXX_TR1_UTILITY