Install gcc-4.4.0-tdm-1-core-2.tar.gz
[msysgit.git] / mingw / lib / gcc / mingw32 / 4.3.3 / include / c++ / tr1_impl / utility
blob42040c9103c8a4ba0cd4456fd8f9bac796a5a378
2 // TR1 utility -*- C++ -*-
4 // Copyright (C) 2007 Free Software Foundation, Inc.
5 //
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 2, or (at your option)
10 // any later version.
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 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING.  If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction.  Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License.  This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
31 /** @file tr1_impl/utility
32  *  This is an internal header file, included by other library headers.
33  *  You should not attempt to use it directly.
34  */
36 namespace std
38 _GLIBCXX_BEGIN_NAMESPACE_TR1
40   template<class _Tp> class tuple_size;
41   template<int _Int, class _Tp> class tuple_element;
43    // Various functions which give std::pair a tuple-like interface.
44   template<class _Tp1, class _Tp2>
45     struct tuple_size<std::pair<_Tp1, _Tp2> >
46     { static const int value = 2; };
48   template<class _Tp1, class _Tp2>
49     const int tuple_size<std::pair<_Tp1, _Tp2> >::value;
51   template<class _Tp1, class _Tp2>
52     struct tuple_element<0, std::pair<_Tp1, _Tp2> >
53     { typedef _Tp1 type; };
55   template<class _Tp1, class _Tp2>
56     struct tuple_element<1, std::pair<_Tp1, _Tp2> >
57     { typedef _Tp2 type; };
60   template<int _Int> struct __pair_get;
62   template<>
63     struct __pair_get<0>
64     {
65       template<typename _Tp1, typename _Tp2>
66       static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
67       { return __pair.first; }
69       template<typename _Tp1, typename _Tp2>
70       static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
71       { return __pair.first; }
72     };
74   template<>
75     struct __pair_get<1>
76     {
77       template<typename _Tp1, typename _Tp2>
78       static _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair)
79       { return __pair.second; }
81       template<typename _Tp1, typename _Tp2>
82       static const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
83       { return __pair.second; }
84     };
86    template<int _Int, class _Tp1, class _Tp2>
87      inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
88      get(std::pair<_Tp1, _Tp2>& __in)
89      { return __pair_get<_Int>::__get(__in); }
91    template<int _Int, class _Tp1, class _Tp2>
92      inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
93      get(const std::pair<_Tp1, _Tp2>& __in)
94      { return __pair_get<_Int>::__const_get(__in); }
96 _GLIBCXX_END_NAMESPACE_TR1