File: utility

package info (click to toggle)
cppreference-doc 20170409-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 259,872 kB
  • sloc: xml: 570,184; python: 1,923; php: 520; makefile: 168; sh: 25; cpp: 9; ansic: 9
file content (149 lines) | stat: -rw-r--r-- 3,974 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    This file is part of cppreference-doc

    This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
    Unported License. To view a copy of this license, visit
    http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
    Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3 or
    any later version published by the Free Software Foundation; with no
    Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/

#ifndef CPPREFERENCE_UTILITY_H
#define CPPREFERENCE_UTILITY_H

#if CPPREFERENCE_STDVER>= 2011
#include <initializer_list>
#endif

namespace std {

#if CPPREFERENCE_STDVER>= 2011
// defined in <algorithm> pre C++11
template<class T>
void swap(T& a, T& b);

template<class T2, size_t N>
void swap(T2(&a)[N], T2(&b)[N]);
#endif

namespace rel_ops {
template<class T>
bool operator!=(const T& lhs, const T& rhs);
template<class T>
bool operator>(const T& lhs, const T& rhs);
template<class T>
bool operator<=(const T& lhs, const T& rhs);
template<class T>
bool operator>=(const T& lhs, const T& rhs);
} // namespace rel_ops

#if CPPREFERENCE_STDVER>= 2014
template<class T, class U = T>
T exchange(T& obj, U && new_value);
#endif

#if CPPREFERENCE_STDVER>= 2011
template<class T>
T&& forward(typename std::remove_reference<T>::type& t);

template<class T>
T&& forward(typename std::remove_reference<T>::type&& t);

template<class T>
typename T&& move(T&& t);   // SIMPLIFIED: return type

template<class T>
typename T&& move_if_noexcept(T&& t);   // SIMPLIFIED: return type

template<class T>
T declval(); // SIMPLIFIED: return type

struct piecewise_construct_t { };
constexpr piecewise_construct_t piecewise_construct;
#endif

template <
    class T1,
    class T2
    > struct pair {
    typedef T1 first_type;
    typedef T2 second_type;
    T1 first;
    T2 second;

    pair();
    pair(const T1& x, const T2& y);

    template<class U1, class U2>
    pair(const pair<U1, U2>& p);

#if CPPREFERENCE_STDVER>= 2011
    template<class U1, class U2>
    pair(U1&& x, U2&& y);

    template<class U1, class U2>
    pair(pair<U1, U2>&& p);

    template<class... Args1, class... Args2>
    pair(std::piecewise_construct_t,
         std::tuple<Args1...> first_args,
         std::tuple<Args2...> second_args);
#endif

    pair(const pair& p);
    pair(pair&& p);

    pair& operator=(const pair& other);

    template<class U1, class U2>
    pair& operator=(const pair<U1, U2>& other);

#if CPPREFERENCE_STDVER>= 2011
    pair& operator=(pair&& other);

    template<class U1, class U2>
    pair& operator=(pair<U1, U2>&& other);
#endif

    void swap(pair& other);
};

template<class T1, class T2>
bool operator==(const pair<T1, T2>& lhs, const pair<T1, T2>& rhs);
template<class T1, class T2>
bool operator!=(const pair<T1, T2>& lhs, const pair<T1, T2>& rhs);
template<class T1, class T2>
bool operator<(const pair<T1, T2>& lhs, const pair<T1, T2>& rhs);
template<class T1, class T2>
bool operator<=(const pair<T1, T2>& lhs, const pair<T1, T2>& rhs);
template<class T1, class T2>
bool operator>(const pair<T1, T2>& lhs, const pair<T1, T2>& rhs);
template<class T1, class T2>
bool operator>=(const pair<T1, T2>& lhs, const pair<T1, T2>& rhs);

#if CPPREFERENCE_STDVER <2011
template<class T1, class T2>
std::pair<T1, T2> make_pair(T1 t, T2 u);
#else
template<class T1, class T2>
std::pair<T1, T2> make_pair(T1&& t, T2&& u);
#endif

template<class T1, class T2>
void swap(pair<T1, T2>& lhs, pair<T1, T2>& rhs);

#if CPPREFERENCE_STDVER>= 2011
template<size_t N, class T1, class T2>
typename std::tuple_element<I, std::pair<T1, T2>>::type&
        get(pair<T1, T2>& p);
// SIMPLIFIED: additional overloads omitted
#endif

} // namespace std

#endif // CPPREFERENCE_UTILITY_H