[1166] | 1 | // TR1 utility -*- C++ -*-
|
---|
| 2 |
|
---|
| 3 | // Copyright (C) 2004-2021 Free Software Foundation, Inc.
|
---|
| 4 | //
|
---|
| 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 3, or (at your option)
|
---|
| 9 | // any later version.
|
---|
| 10 |
|
---|
| 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.
|
---|
| 15 |
|
---|
| 16 | // Under Section 7 of GPL version 3, you are granted additional
|
---|
| 17 | // permissions described in the GCC Runtime Library Exception, version
|
---|
| 18 | // 3.1, as published by the Free Software Foundation.
|
---|
| 19 |
|
---|
| 20 | // You should have received a copy of the GNU General Public License and
|
---|
| 21 | // a copy of the GCC Runtime Library Exception along with this program;
|
---|
| 22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
---|
| 23 | // <http://www.gnu.org/licenses/>.
|
---|
| 24 |
|
---|
| 25 | /** @file tr1/utility
|
---|
| 26 | * This is a TR1 C++ Library header.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | #ifndef _GLIBCXX_TR1_UTILITY
|
---|
| 30 | #define _GLIBCXX_TR1_UTILITY 1
|
---|
| 31 |
|
---|
| 32 | #pragma GCC system_header
|
---|
| 33 |
|
---|
| 34 | #include <bits/c++config.h>
|
---|
| 35 | #include <bits/stl_relops.h>
|
---|
| 36 | #include <bits/stl_pair.h>
|
---|
| 37 |
|
---|
| 38 | namespace std _GLIBCXX_VISIBILITY(default)
|
---|
| 39 | {
|
---|
| 40 | _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
---|
| 41 |
|
---|
| 42 | namespace tr1
|
---|
| 43 | {
|
---|
| 44 | template<class _Tp>
|
---|
| 45 | class tuple_size;
|
---|
| 46 |
|
---|
| 47 | template<int _Int, class _Tp>
|
---|
| 48 | class tuple_element;
|
---|
| 49 |
|
---|
| 50 | // Various functions which give std::pair a tuple-like interface.
|
---|
| 51 | template<class _Tp1, class _Tp2>
|
---|
| 52 | struct tuple_size<std::pair<_Tp1, _Tp2> >
|
---|
| 53 | { static const int value = 2; };
|
---|
| 54 |
|
---|
| 55 | template<class _Tp1, class _Tp2>
|
---|
| 56 | const int
|
---|
| 57 | tuple_size<std::pair<_Tp1, _Tp2> >::value;
|
---|
| 58 |
|
---|
| 59 | template<class _Tp1, class _Tp2>
|
---|
| 60 | struct tuple_element<0, std::pair<_Tp1, _Tp2> >
|
---|
| 61 | { typedef _Tp1 type; };
|
---|
| 62 |
|
---|
| 63 | template<class _Tp1, class _Tp2>
|
---|
| 64 | struct tuple_element<1, std::pair<_Tp1, _Tp2> >
|
---|
| 65 | { typedef _Tp2 type; };
|
---|
| 66 |
|
---|
| 67 | template<int _Int>
|
---|
| 68 | struct __pair_get;
|
---|
| 69 |
|
---|
| 70 | template<>
|
---|
| 71 | struct __pair_get<0>
|
---|
| 72 | {
|
---|
| 73 | template<typename _Tp1, typename _Tp2>
|
---|
| 74 | static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair)
|
---|
| 75 | { return __pair.first; }
|
---|
| 76 |
|
---|
| 77 | template<typename _Tp1, typename _Tp2>
|
---|
| 78 | static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
|
---|
| 79 | { return __pair.first; }
|
---|
| 80 | };
|
---|
| 81 |
|
---|
| 82 | template<>
|
---|
| 83 | struct __pair_get<1>
|
---|
| 84 | {
|
---|
| 85 | template<typename _Tp1, typename _Tp2>
|
---|
| 86 | static _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair)
|
---|
| 87 | { return __pair.second; }
|
---|
| 88 |
|
---|
| 89 | template<typename _Tp1, typename _Tp2>
|
---|
| 90 | static const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair)
|
---|
| 91 | { return __pair.second; }
|
---|
| 92 | };
|
---|
| 93 |
|
---|
| 94 | template<int _Int, class _Tp1, class _Tp2>
|
---|
| 95 | inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
|
---|
| 96 | get(std::pair<_Tp1, _Tp2>& __in)
|
---|
| 97 | { return __pair_get<_Int>::__get(__in); }
|
---|
| 98 |
|
---|
| 99 | template<int _Int, class _Tp1, class _Tp2>
|
---|
| 100 | inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
|
---|
| 101 | get(const std::pair<_Tp1, _Tp2>& __in)
|
---|
| 102 | { return __pair_get<_Int>::__const_get(__in); }
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | _GLIBCXX_END_NAMESPACE_VERSION
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | #endif // _GLIBCXX_TR1_UTILITY
|
---|