/usr/include/tbb/compat/tuple is in libtbb-dev 4.0+r233-1.
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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | /*
Copyright 2005-2011 Intel Corporation. All Rights Reserved.
This file is part of Threading Building Blocks.
Threading Building Blocks is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
Threading Building Blocks 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.
You should have received a copy of the GNU General Public License
along with Threading Building Blocks; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
As a special exception, you may use this file as part of a free software
library without restriction. Specifically, if other files instantiate
templates or use macros or inline functions from this file, or you compile
this file and link it with other files to produce an executable, this
file does not by itself cause the resulting executable to be covered by
the GNU General Public License. This exception does not however
invalidate any other reasons why the executable file might be covered by
the GNU General Public License.
*/
#ifndef __TBB_tuple_H
#define __TBB_tuple_H
#if !TBB_PREVIEW_TUPLE
#error Set TBB_PREVIEW_TUPLE to include compat/tuple
#endif
#include <utility>
#include "../tbb_stddef.h"
namespace tbb {
namespace interface5 {
namespace internal {
struct null_type { };
}
using internal::null_type;
// tuple forward declaration
template <class T0=null_type, class T1=null_type, class T2=null_type, class T3=null_type, class T4=null_type, class T5=null_type, class T6=null_type, class T7=null_type, class T8=null_type, class T9=null_type>
class tuple;
namespace internal {
// const null_type temp
inline const null_type cnull() { return null_type(); }
// cons forward declaration
template <class HT, class TT> struct cons;
// type of a component of the cons
template<int N, class T>
struct component {
typedef typename T::tail_type next;
typedef typename component<N-1,next>::type type;
};
template<class T>
struct component<0,T> {
typedef typename T::head_type type;
};
template<>
struct component<0,null_type> {
typedef null_type type;
};
// const version of component
template<int N, class T>
struct component<N, const T>
{
typedef typename T::tail_type next;
typedef typename component<N-1,next>::type type;
};
template<class T>
struct component<0, const T>
{
typedef const typename T::head_type type;
};
// helper class for getting components of cons
template< int N>
struct get_helper {
template<class HT, class TT>
inline static typename component<N, cons<HT,TT> >::type& get(cons<HT,TT>& ti) {
return get_helper<N-1>::get(ti.tail);
}
};
template<>
struct get_helper<0> {
template<class HT, class TT>
inline static typename component<0, cons<HT,TT> >::type& get(cons<HT,TT>& ti) {
return ti.head;
}
};
// traits adaptor
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9>
struct tuple_traits {
typedef cons <T0, typename tuple_traits<T1, T2, T3, T4, T5, T6, T7, T8, T9, null_type>::U > U;
};
template <>
struct tuple_traits<class T0, null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type> {
typedef cons<T0, null_type> U;
};
template<>
struct tuple_traits<null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type> {
typedef null_type U;
};
// core cons defs
template <class HT, class TT>
struct cons{
typedef HT head_type;
typedef TT tail_type;
HT head;
TT tail;
static const int length = 1 + tail_type::length;
// default constructors
explicit cons() : head(), tail() { }
// non-default constructors
cons(head_type& h, const tail_type& t) : head(h), tail(t) { }
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9>
cons(const T0& t0, const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5, const T6& t6, const T7& t7, const T8& t8, const T9& t9) :
head(t0), tail(t1, t2, t3, t4, t5, t6, t7, t8, t9, cnull()) { }
template <class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9>
cons(T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8, T9& t9) :
head(t0), tail(t1, t2, t3, t4, t5, t6, t7, t8, t9, cnull()) { }
template <class HT1, class TT1>
cons(const cons<HT1,TT1>& other) : head(other.head), tail(other.tail) { }
cons& operator=(const cons& other) { head = other.head; tail = other.tail; return *this; }
friend bool operator==(const cons& me, const cons& other) {
return me.head == other.head && me.tail == other.tail;
}
friend bool operator<(const cons& me, const cons& other) {
return me.head < other.head || (!(other.head < me.head) && me.tail < other.tail);
}
friend bool operator>(const cons& me, const cons& other) { return other<me; }
friend bool operator!=(const cons& me, const cons& other) { return !(me==other); }
friend bool operator>=(const cons& me, const cons& other) { return !(me<other); }
friend bool operator<=(const cons& me, const cons& other) { return !(me>other); }
template<class HT1, class TT1>
friend bool operator==(const cons<HT,TT>& me, const cons<HT1,TT1>& other) {
return me.head == other.head && me.tail == other.tail;
}
template<class HT1, class TT1>
friend bool operator<(const cons<HT,TT>& me, const cons<HT1,TT1>& other) {
return me.head < other.head || (!(other.head < me.head) && me.tail < other.tail);
}
template<class HT1, class TT1>
friend bool operator>(const cons<HT,TT>& me, const cons<HT1,TT1>& other) { return other<me; }
template<class HT1, class TT1>
friend bool operator!=(const cons<HT,TT>& me, const cons<HT1,TT1>& other) { return !(me==other); }
template<class HT1, class TT1>
friend bool operator>=(const cons<HT,TT>& me, const cons<HT1,TT1>& other) { return !(me<other); }
template<class HT1, class TT1>
friend bool operator<=(const cons<HT,TT>& me, const cons<HT1,TT1>& other) { return !(me>other); }
}; // cons
template <class HT>
struct cons<HT,null_type> {
typedef HT head_type;
typedef null_type tail_type;
static const int length = 1;
head_type head;
// default constructor
cons() : head() { /*std::cout << "default constructor 1\n";*/ }
cons(const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&) : head() { /*std::cout << "default constructor 2\n";*/ }
// non-default constructor
template<class T1>
cons(T1& t1, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type& ) : head(t1) { /*std::cout << "non-default a1, t1== " << t1 << "\n";*/}
cons(head_type& h, const null_type& = null_type() ) : head(h) { }
cons(const head_type& t0, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&) : head(t0) { }
// converting constructor
template<class HT1>
cons(HT1 h1, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&, const null_type&) : head(h1) { }
// copy constructor
template<class HT1>
cons( const cons<HT1, null_type>& other) : head(other.head) { }
// assignment operator
cons& operator=(const cons& other) { head = other.head; return *this; }
friend bool operator==(const cons& me, const cons& other) { return me.head == other.head; }
friend bool operator<(const cons& me, const cons& other) { return me.head < other.head; }
friend bool operator>(const cons& me, const cons& other) { return other<me; }
friend bool operator!=(const cons& me, const cons& other) {return !(me==other); }
friend bool operator<=(const cons& me, const cons& other) {return !(me>other); }
friend bool operator>=(const cons& me, const cons& other) {return !(me<other); }
template<class HT1>
friend bool operator==(const cons<HT,null_type>& me, const cons<HT1,null_type>& other) {
return me.head == other.head;
}
template<class HT1>
friend bool operator<(const cons<HT,null_type>& me, const cons<HT1,null_type>& other) {
return me.head < other.head;
}
template<class HT1>
friend bool operator>(const cons<HT,null_type>& me, const cons<HT1,null_type>& other) { return other<me; }
template<class HT1>
friend bool operator!=(const cons<HT,null_type>& me, const cons<HT1,null_type>& other) { return !(me==other); }
template<class HT1>
friend bool operator<=(const cons<HT,null_type>& me, const cons<HT1,null_type>& other) { return !(me>other); }
template<class HT1>
friend bool operator>=(const cons<HT,null_type>& me, const cons<HT1,null_type>& other) { return !(me<other); }
}; // cons
template <>
struct cons<null_type,null_type> { typedef null_type tail_type; static const int length = 0; };
// wrapper for default constructor
template<class T>
inline const T wrap_dcons(T*) { return T(); }
} // namespace internal
// tuple definition
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9>
class tuple : public internal::tuple_traits<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::U {
// friends
template <class T> friend class tuple_size;
template<int N, class T> friend struct tuple_element;
// stl components
typedef tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> value_type;
typedef value_type *pointer;
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
typedef size_t size_type;
typedef typename internal::tuple_traits<T0,T1,T2,T3, T4, T5, T6, T7, T8, T9>::U my_cons;
public:
tuple(const T0& t0=internal::wrap_dcons((T0*)NULL),
const T1& t1=internal::wrap_dcons((T1*)NULL),
const T2& t2=internal::wrap_dcons((T2*)NULL),
const T3& t3=internal::wrap_dcons((T3*)NULL),
const T4& t4=internal::wrap_dcons((T4*)NULL),
const T5& t5=internal::wrap_dcons((T5*)NULL),
const T6& t6=internal::wrap_dcons((T6*)NULL),
const T7& t7=internal::wrap_dcons((T7*)NULL),
const T8& t8=internal::wrap_dcons((T8*)NULL),
const T9& t9=internal::wrap_dcons((T9*)NULL)
) :
internal::tuple_traits<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>::U(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9) { }
template<int N>
struct internal_tuple_element {
typedef typename internal::component<N,my_cons>::type type;
};
template<int N>
typename internal_tuple_element<N>::type& get() { return internal::get_helper<N>::get(*this); }
template<class U1, class U2>
tuple& operator=(const internal::cons<U1,U2>& other) {
my_cons::operator=(other);
return *this;
}
template<class U1, class U2>
tuple& operator=(const std::pair<U1,U2>& other) {
// __TBB_ASSERT(tuple_size<value_type>::value == 2, "Invalid size for pair to tuple assignment");
this->head = other.first;
this->tail.head = other.second;
return *this;
}
friend bool operator==(const tuple& me, const tuple& other) {return static_cast<const my_cons &>(me)==(other);}
friend bool operator<(const tuple& me, const tuple& other) {return static_cast<const my_cons &>(me)<(other);}
friend bool operator>(const tuple& me, const tuple& other) {return static_cast<const my_cons &>(me)>(other);}
friend bool operator!=(const tuple& me, const tuple& other) {return static_cast<const my_cons &>(me)!=(other);}
friend bool operator>=(const tuple& me, const tuple& other) {return static_cast<const my_cons &>(me)>=(other);}
friend bool operator<=(const tuple& me, const tuple& other) {return static_cast<const my_cons &>(me)<=(other);}
template<class U0, class U1, class U2, class U3, class U4, class U5, class U6, class U7, class U8, class U9>
friend bool operator==(const tuple& me, const tuple<U0,U1,U2,U3,U4,U5,U6,U7,U8,U9>& other) {
return static_cast<const my_cons &>(me)==(other);
}
template<class U0, class U1, class U2, class U3, class U4, class U5, class U6, class U7, class U8, class U9>
friend bool operator<(const tuple& me, const tuple<U0,U1,U2,U3,U4,U5,U6,U7,U8,U9>& other) {
return static_cast<const my_cons &>(me)<(other);
}
template<class U0, class U1, class U2, class U3, class U4, class U5, class U6, class U7, class U8, class U9>
friend bool operator>(const tuple& me, const tuple<U0,U1,U2,U3,U4,U5,U6,U7,U8,U9>& other) {
return static_cast<const my_cons &>(me)>(other);
}
template<class U0, class U1, class U2, class U3, class U4, class U5, class U6, class U7, class U8, class U9>
friend bool operator!=(const tuple& me, const tuple<U0,U1,U2,U3,U4,U5,U6,U7,U8,U9>& other) {
return static_cast<const my_cons &>(me)!=(other);
}
template<class U0, class U1, class U2, class U3, class U4, class U5, class U6, class U7, class U8, class U9>
friend bool operator>=(const tuple& me, const tuple<U0,U1,U2,U3,U4,U5,U6,U7,U8,U9>& other) {
return static_cast<const my_cons &>(me)>=(other);
}
template<class U0, class U1, class U2, class U3, class U4, class U5, class U6, class U7, class U8, class U9>
friend bool operator<=(const tuple& me, const tuple<U0,U1,U2,U3,U4,U5,U6,U7,U8,U9>& other) {
return static_cast<const my_cons &>(me)<=(other);
}
}; // tuple
// empty tuple
template<>
class tuple<null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type, null_type> : public null_type {
typedef null_type inherited;
};
// helper classes
template < class T>
class tuple_size {
public:
static const size_t value = 1 + tuple_size<typename T::tail_type>::value;
};
template <>
class tuple_size<tuple<> > {
public:
static const size_t value = 0;
};
template <>
class tuple_size<null_type> {
public:
static const size_t value = 0;
};
template<int N, class T>
struct tuple_element {
typedef typename internal::component<N, typename T::my_cons>::type type;
};
template<int N, class T>
inline static typename tuple_element<N,T>::type& get(T &t) { return t.get<N>(); }
template<int N, class T>
inline static typename tuple_element<N,T>::type const& get(T const &t) { return
const_cast<typename tuple_element<N,T>::type const &>
(const_cast<T &>(t).get<N>()); }
} // interface5
} // tbb
#if TBB_IMPLEMENT_CPP0X
namespace std {
using tbb::interface5::tuple;
using tbb::interface5::tuple_size;
using tbb::interface5::tuple_element;
using tbb::interface5::get;
}
#endif
#endif /* __TBB_tuple_H */
|