/usr/include/polymake/pair.h is in libpolymake-dev-common 3.2r2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | /* Copyright (c) 1997-2018
Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
http://www.polymake.org
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version: http://www.gnu.org/licenses/gpl.txt.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
--------------------------------------------------------------------------------
*/
#ifndef POLYMAKE_PAIR_H
#define POLYMAKE_PAIR_H
#include "polymake/internal/comparators_basic_defs.h"
#include "polymake/internal/nothing.h"
#include <utility>
namespace pm {
using std::pair;
template <typename U1, typename U2, typename Target, bool _whole=isomorphic_types<pair<U1,U2>, Target>::value>
struct pair_chooser {
typedef const pair<U1,U2>& first_type;
typedef first_type second_type;
static first_type first(first_type u) { return u; }
static first_type second(first_type u) { return u; }
};
template <typename U1, typename U2, typename Target>
struct pair_chooser<U1, U2, Target, false> {
typedef typename attrib<U1>::plus_const_ref first_type;
typedef typename attrib<U2>::plus_const_ref second_type;
static first_type first(const pair<U1,U2>& u) { return u.first; }
static second_type second(const pair<U1,U2>& u) { return u.second; }
};
template <typename Target, typename U1, typename U2> inline
typename pair_chooser<U1, U2, Target>::first_type
pair_init_first(const pair<U1,U2>& u)
{
return pair_chooser<U1, U2, Target>::first(u);
}
template <typename Target, typename U1, typename U2> inline
typename pair_chooser<U1, U2, Target>::first_type
pair_init_second(const pair<U1,U2>& u)
{
return pair_chooser<U1, U2, Target>::second(u);
}
template <typename Data, typename NonPair>
struct isomorphic_to_first : std::false_type {};
template <typename Data, typename T1, typename T2>
struct isomorphic_to_first< Data, pair<T1,T2> > : isomorphic_types<typename deref<T1>::type, Data> {};
template <typename Data, typename NonPair>
struct isomorphic_to_second : std::false_type {};
template <typename Data, typename T1, typename T2>
struct isomorphic_to_second< Data, pair<T1,T2> > : isomorphic_types<typename deref<T2>::type, Data> {};
}
namespace std {
template <typename T1, typename T2>
struct pair<T1&, T2> {
typedef T1& first_type;
typedef T2 second_type;
/// data types referred to by the components
typedef T1 first_data_type;
typedef T2 second_data_type;
first_type first;
second_type second;
pair(T1& first_arg, const T2& second_arg) : first(first_arg), second(second_arg) {}
template <typename U1, typename U2>
explicit pair(const pair<U1&,U2>& p) : first(p.first), second(p.second) {}
};
template <typename T1, typename T2>
struct pair<T1, T2&> {
typedef T1 first_type;
typedef T2& second_type;
typedef T1 first_data_type;
typedef T2 second_data_type;
first_type first;
second_type second;
pair(const T1& first_arg, T2& second_arg) : first(first_arg), second(second_arg) {}
template <typename U1, typename U2>
explicit pair(const pair<U1,U2&>& p) : first(p.first), second(p.second) {}
};
template <typename T1, typename T2>
struct pair<T1&, T2&> {
typedef T1& first_type;
typedef T2& second_type;
typedef T1 first_data_type;
typedef T2 second_data_type;
first_type first;
second_type second;
pair(T1& first_arg, T2& second_arg) : first(first_arg), second(second_arg) {}
template <typename U1, typename U2>
explicit pair(const pair<U1&,U2&>& p) : first(p.first), second(p.second) {}
};
template <typename T1>
struct pair<T1, pm::nothing> {
typedef T1 first_type;
typedef pm::nothing second_type;
typedef T1 first_data_type;
typedef pm::nothing second_data_type;
first_type first;
static pm::nothing second;
pair() {}
template <typename U1, typename=typename enable_if<is_constructible<T1, polymake::pure_type_t<U1>>::value>::type>
explicit pair(U1&& first_arg)
: first(forward<U1>(first_arg)) {}
template <typename U1, typename=typename enable_if<is_constructible<T1, polymake::pure_type_t<U1>>::value>::type>
pair(U1&& first_arg, const pm::nothing&)
: first(forward<U1>(first_arg)) {}
template <typename U1, typename U2, typename=typename enable_if<is_constructible<T1, polymake::pure_type_t<U1>>::value>::type>
explicit pair(const pair<U1, U2>& u)
: first(pm::pair_init_first<T1>(u)) {}
};
template <typename T1> pm::nothing pair<T1,pm::nothing>::second;
template <typename T1>
struct pair<T1&, pm::nothing> {
typedef T1& first_type;
typedef pm::nothing second_type;
typedef T1 first_data_type;
typedef pm::nothing second_data_type;
first_type first;
static pm::nothing second;
explicit pair(T1& first_arg) : first(first_arg) {}
pair(T1& first_arg, const pm::nothing&) : first(first_arg) {}
template <typename U1, typename U2>
explicit pair(const pair<U1&, U2>& u) : first(pm::pair_init_first<T1>(u)) {}
};
template <typename T1> pm::nothing pair<T1&, pm::nothing>::second;
template <typename T2>
struct pair<pm::nothing, T2> {
typedef pm::nothing first_type;
typedef T2 second_type;
typedef pm::nothing first_data_type;
typedef T2 second_data_type;
static pm::nothing first;
second_type second;
pair() {}
template <typename U2, typename=typename enable_if<is_constructible<T2, polymake::pure_type_t<U2>>::value>::type>
explicit pair(U2&& second_arg)
: second(forward<U2>(second_arg)) {}
template <typename U2, typename=typename enable_if<is_constructible<T2, polymake::pure_type_t<U2>>::value>::type>
pair(const pm::nothing&, U2&& second_arg)
: second(forward<U2>(second_arg)) {}
template <typename U1, typename U2, typename=typename enable_if<is_constructible<T2, polymake::pure_type_t<U2>>::value>::type>
explicit pair(const pair<U1, U2>& u)
: second(pm::pair_init_second<T2>(u)) {}
};
template <typename T2> pm::nothing pair<pm::nothing, T2>::first;
template <typename T2>
struct pair<pm::nothing, T2&> {
typedef pm::nothing first_type;
typedef T2& second_type;
typedef pm::nothing first_data_type;
typedef T2 second_data_type;
static pm::nothing first;
second_type second;
explicit pair(T2& second_arg)
: second(second_arg) {}
pair(const pm::nothing&, T2& second_arg)
: second(second_arg) {}
template <typename U1, typename U2>
explicit pair(const pair<U1, U2&>& u) : second(pm::pair_init_second<T2>(u)) {}
};
template <typename T2> pm::nothing pair<pm::nothing, T2&>::first;
template <>
struct pair<pm::nothing, pm::nothing> {
typedef pm::nothing first_type;
typedef pm::nothing second_type;
typedef pm::nothing first_data_type;
typedef pm::nothing second_data_type;
static pm::nothing first, second;
pair() {}
explicit pair(const pm::nothing&) {}
pair(const pm::nothing&, const pm::nothing&) {}
template <typename U1, typename U2>
explicit pair(const pair<U1,U2>&) {}
};
} // end namespace std
namespace pm {
template <typename T1, typename T2>
struct spec_object_traits< pair<T1,T2> > : spec_object_traits<is_composite> {
typedef cons<T1,T2> elements;
template <typename Me, typename Visitor>
static void visit_elements(Me& x, Visitor& v)
{
v << x.first << x.second;
}
};
namespace operations {
template <typename T1, typename T2>
struct pair_maker {
typedef T1 first_argument_type;
typedef T2 second_argument_type;
typedef pair<T1,T2> result_type;
result_type operator() (typename function_argument<T1>::type first_arg,
typename function_argument<T2>::type second_arg) const
{
return result_type(first_arg,second_arg);
}
};
template <typename PairRef>
struct take_first {
typedef PairRef argument_type;
typedef typename inherit_ref<typename deref<PairRef>::type::first_type, PairRef>::type result_type;
result_type operator() (typename function_argument<PairRef>::type arg) const { return arg.first; }
};
template <typename PairRef>
struct take_second {
typedef PairRef argument_type;
typedef typename inherit_ref<typename deref<PairRef>::type::second_type, PairRef>::type result_type;
result_type operator() (typename function_argument<PairRef>::type arg) const { return arg.second; }
};
} // end namespace operations
template <typename Container> inline
pair<typename Container::const_reference, typename Container::const_reference>
front_pair(const Container& c)
{
typename Container::const_iterator it=c.begin();
typename Container::const_reference e1=*it, e2=*(++it);
return pair<typename Container::const_reference, typename Container::const_reference>(e1,e2);
}
template <typename Container> inline
pair<typename Container::const_reference, typename Container::const_reference>
back_pair(const Container& c)
{
typename Container::const_reverse_iterator it=c.rbegin();
typename Container::const_reference e1=*it, e2=*(++it);
return pair<typename Container::const_reference, typename Container::const_reference>(e1,e2);
}
} // end namespace pm
#endif // POLYMAKE_PAIR_H
// Local Variables:
// mode:C++
// c-basic-offset:3
// indent-tabs-mode:nil
// End:
|