~ubuntu-branches/ubuntu/wily/davix/wily

« back to all changes in this revision

Viewing changes to deps/boost_intern/boost/container/detail/variadic_templates_tools.hpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2015-07-31 13:17:55 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20150731131755-mizprbmn7ogv33te
Tags: 0.4.1-1
* Update to version 0.4.1
* Implement Multi-Arch support

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//////////////////////////////////////////////////////////////////////////////
2
 
//
3
 
// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
4
 
// Software License, Version 1.0. (See accompanying file
5
 
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
 
//
7
 
// See http://www.boost.org/libs/container for documentation.
8
 
//
9
 
//////////////////////////////////////////////////////////////////////////////
10
 
 
11
 
#ifndef BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP
12
 
#define BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP
13
 
 
14
 
#if defined(_MSC_VER)
15
 
#  pragma once
16
 
#endif
17
 
 
18
 
#include "config_begin.hpp"
19
 
#include <boost/container/detail/workaround.hpp>
20
 
#include <boost/container/detail/type_traits.hpp>
21
 
#include <cstddef>   //std::size_t
22
 
 
23
 
namespace boost {
24
 
namespace container {
25
 
namespace container_detail {
26
 
 
27
 
template<typename... Values>
28
 
class tuple;
29
 
 
30
 
template<> class tuple<>
31
 
{};
32
 
 
33
 
template<typename Head, typename... Tail>
34
 
class tuple<Head, Tail...>
35
 
   : private tuple<Tail...>
36
 
{
37
 
   typedef tuple<Tail...> inherited;
38
 
 
39
 
   public:
40
 
   tuple() { }
41
 
 
42
 
   // implicit copy-constructor is okay
43
 
   // Construct tuple from separate arguments.
44
 
   tuple(typename add_const_reference<Head>::type v,
45
 
         typename add_const_reference<Tail>::type... vtail)
46
 
   : inherited(vtail...), m_head(v)
47
 
   {}
48
 
 
49
 
   // Construct tuple from another tuple.
50
 
   template<typename... VValues>
51
 
   tuple(const tuple<VValues...>& other)
52
 
      : m_head(other.head()), inherited(other.tail())
53
 
   {}
54
 
 
55
 
   template<typename... VValues>
56
 
   tuple& operator=(const tuple<VValues...>& other)
57
 
   {
58
 
      m_head = other.head();
59
 
      tail() = other.tail();
60
 
      return this;
61
 
   }
62
 
 
63
 
   typename add_reference<Head>::type head()             {  return m_head; }
64
 
   typename add_reference<const Head>::type head() const {  return m_head; }
65
 
 
66
 
   inherited& tail()             { return *this; }
67
 
   const inherited& tail() const { return *this; }
68
 
 
69
 
   protected:
70
 
   Head m_head;
71
 
};
72
 
 
73
 
 
74
 
template<typename... Values>
75
 
tuple<Values&&...> tie_forward(Values&&... values)
76
 
{ return tuple<Values&&...>(values...); }
77
 
 
78
 
template<int I, typename Tuple>
79
 
struct tuple_element;
80
 
 
81
 
template<int I, typename Head, typename... Tail>
82
 
struct tuple_element<I, tuple<Head, Tail...> >
83
 
{
84
 
   typedef typename tuple_element<I-1, tuple<Tail...> >::type type;
85
 
};
86
 
 
87
 
template<typename Head, typename... Tail>
88
 
struct tuple_element<0, tuple<Head, Tail...> >
89
 
{
90
 
   typedef Head type;
91
 
};
92
 
 
93
 
template<int I, typename Tuple>
94
 
class get_impl;
95
 
 
96
 
template<int I, typename Head, typename... Values>
97
 
class get_impl<I, tuple<Head, Values...> >
98
 
{
99
 
   typedef typename tuple_element<I-1, tuple<Values...> >::type   Element;
100
 
   typedef get_impl<I-1, tuple<Values...> >                       Next;
101
 
 
102
 
   public:
103
 
   typedef typename add_reference<Element>::type                  type;
104
 
   typedef typename add_const_reference<Element>::type            const_type;
105
 
   static type get(tuple<Head, Values...>& t)              { return Next::get(t.tail()); }
106
 
   static const_type get(const tuple<Head, Values...>& t)  { return Next::get(t.tail()); }
107
 
};
108
 
 
109
 
template<typename Head, typename... Values>
110
 
class get_impl<0, tuple<Head, Values...> >
111
 
{
112
 
   public:
113
 
   typedef typename add_reference<Head>::type         type;
114
 
   typedef typename add_const_reference<Head>::type   const_type;
115
 
   static type       get(tuple<Head, Values...>& t)      { return t.head(); }
116
 
   static const_type get(const tuple<Head, Values...>& t){ return t.head(); }
117
 
};
118
 
 
119
 
template<int I, typename... Values>
120
 
typename get_impl<I, tuple<Values...> >::type get(tuple<Values...>& t)
121
 
{  return get_impl<I, tuple<Values...> >::get(t);  }
122
 
 
123
 
template<int I, typename... Values>
124
 
typename get_impl<I, tuple<Values...> >::const_type get(const tuple<Values...>& t)
125
 
{  return get_impl<I, tuple<Values...> >::get(t);  }
126
 
 
127
 
////////////////////////////////////////////////////
128
 
// Builds an index_tuple<0, 1, 2, ..., Num-1>, that will
129
 
// be used to "unpack" into comma-separated values
130
 
// in a function call.
131
 
////////////////////////////////////////////////////
132
 
 
133
 
template<int... Indexes>
134
 
struct index_tuple{};
135
 
 
136
 
template<std::size_t Num, typename Tuple = index_tuple<> >
137
 
struct build_number_seq;
138
 
 
139
 
template<std::size_t Num, int... Indexes>
140
 
struct build_number_seq<Num, index_tuple<Indexes...> >
141
 
   : build_number_seq<Num - 1, index_tuple<Indexes..., sizeof...(Indexes)> >
142
 
{};
143
 
 
144
 
template<int... Indexes>
145
 
struct build_number_seq<0, index_tuple<Indexes...> >
146
 
{  typedef index_tuple<Indexes...> type;  };
147
 
 
148
 
 
149
 
}}}   //namespace boost { namespace container { namespace container_detail {
150
 
 
151
 
#include <boost/container/detail/config_end.hpp>
152
 
 
153
 
#endif   //#ifndef BOOST_CONTAINER_DETAIL_VARIADIC_TEMPLATES_TOOLS_HPP