1 // TR1 utility -*- C++ -*-
3 // Copyright (C) 2004 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 * This is a TR1 C++ Library header.
26 #define _TR1_UTILITY 1
34 template<class _Tp> class tuple_size;
35 template<int _Int, class _Tp> class tuple_element;
37 // Various functions which give std::pair a tuple-like interface.
38 template<class _Tp1, class _Tp2>
39 struct tuple_size<std::pair<_Tp1, _Tp2> >
40 { static const int value = 2; };
42 template<class _Tp1, class _Tp2>
43 struct tuple_element<0, std::pair<_Tp1, _Tp2> >
44 { typedef _Tp1 type; };
46 template<class _Tp1, class _Tp2>
47 struct tuple_element<1, std::pair<_Tp1, _Tp2> >
48 { typedef _Tp2 type; };
51 template<int _Int> struct __pair_get;
56 template<typename _Tp1, typename _Tp2>
57 static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
58 { return __pair.first; }
60 template<typename _Tp1, typename _Tp2>
61 static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
62 { return __pair.first; }
68 template<typename _Tp1, typename _Tp2>
69 static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
70 { return __pair.second; }
72 template<typename _Tp1, typename _Tp2>
73 static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
74 { return __pair.second; }
77 template<int _I, class _Tp1, class _Tp2>
78 typename tuple_element<_I, std::pair<_Tp1, _Tp2> >::type&
79 get(pair<_Tp1, _Tp2>& __in)
80 { return __pair_get<_I>::__get(__in); }
82 template<int _I, class _Tp1, class _Tp2>
83 const typename tuple_element<_I, std::pair<_Tp1, _Tp2> >::type&
84 get(const pair<_Tp1, _Tp2>& __in)
85 { return __pair_get<_I>::__const_get(__in); }