Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tuple.hpp « std - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2212bac4360f0dc6ed7b0ab8317d5b59ab2e94a5 (plain)
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
#pragma once
#include "common_defines.hpp"

#ifdef new
#undef new
#endif

#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
using boost::tuple;
using boost::make_tuple;
//using boost::get; // "get" is very common name, use "get" member function

/*
#include <tr1/tuple>
using std::tr1::tuple;
using std::tr1::make_tuple;
using std::tr1::get;
*/

template <class Tuple> struct tuple_length
{
  static const int value = boost::tuples::length<Tuple>::value;
};

template <int N, class T> struct tuple_element
{
  typedef typename boost::tuples::element<N, T>::type type;
};

namespace impl
{
  template <int N> struct for_each_tuple_impl
  {
    template <class Tuple, class ToDo> void operator() (Tuple & t, ToDo & toDo)
    {
      toDo(boost::tuples::get<N>(t), N);
      for_each_tuple_impl<N-1> c;
      c(t, toDo);
    }
  };

  template <> struct for_each_tuple_impl<-1>
  {
    template <class Tuple, class ToDo> void operator() (Tuple &, ToDo &) {}
  };
}

template <class Tuple, class ToDo>
void for_each_tuple(Tuple & t, ToDo & toDo)
{
  impl::for_each_tuple_impl<tuple_length<Tuple>::value-1> c;
  c(t, toDo);
}

#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif