Pothos  0.7.0-gf7fbae99
The Pothos dataflow programming software suite
Templates.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
13 #include <type_traits> //std::decay
14 #include <functional> //std::reference_wrapper
15 
16 namespace Pothos {
17 namespace Util {
18 
19 /*!*********************************************************************
20  * \defgroup unwrapref Implementation for unwrap_refwrapper and special_decay_t
21  * special_decay_t = decay + unwrapping a reference wrapper
22  * \see http://en.cppreference.com/w/cpp/utility/tuple/make_tuple
23  * \{
24  **********************************************************************/
25 
30 template <typename T>
32 {
33  using type = T;
34 };
35 
40 template <typename T>
41 struct unwrap_refwrapper<std::reference_wrapper<T>>
42 {
43  using type = T&;
44 };
45 
50 template <typename T>
53 
54 /*!*********************************************************************
55  * \defgroup intseq Integer sequence implementation for C++11
56  * This can be removed when C++14 is required.
57  * \see http://en.cppreference.com/w/cpp/utility/integer_sequence
58  * \{
59  **********************************************************************/
60 
66 template<typename T, T... Ints>
68 {
69  typedef T value_type;
70 
72  static constexpr std::size_t size(void) noexcept
73  {
74  return sizeof...(Ints);
75  }
76 };
77 
79 template<typename T, int N, T... Ints>
80 struct GenSeq : GenSeq<T, N-1, T(N-1), Ints...> {};
81 
82 template<typename T, T... Ints>
83 struct GenSeq<T, 0, Ints...>
84 {
85  typedef integer_sequence<T, Ints...> Type;
86 };
88 
93 template<std::size_t... Ints>
94 using index_sequence = integer_sequence<std::size_t, Ints...>;
95 
101 template<typename T, T N>
102 using make_integer_sequence = typename GenSeq<T, int(N)>::Type;
103 
108 template<std::size_t N>
110 
115 template<typename... T>
118 
119 /*!*********************************************************************
120  * Disable SFINAE type used with universal reference constructors
121  * \see http://ericniebler.com/2013/08/07/universal-references-and-the-copy-constructo/
122  **********************************************************************/
123 template<typename BaseType, typename OtherType>
124 using disable_if_same = typename std::enable_if<
125  not std::is_same<BaseType, typename std::decay<OtherType>::type>::value>::type;
126 
127 } //namespace Util
128 } //namespace Pothos
make_index_sequence< sizeof...(T)> index_sequence_for
Definition: Templates.hpp:116
make_integer_sequence< std::size_t, N > make_index_sequence
Definition: Templates.hpp:109
T & type
the type held within a reference wrapper
Definition: Templates.hpp:43
Definition: Templates.hpp:67
Definition: ArchiveEntry.hpp:20
typename GenSeq< T, int(N)>::Type make_integer_sequence
Definition: Templates.hpp:102
typename std::enable_if< not std::is_same< BaseType, typename std::decay< OtherType >::type >::value >::type disable_if_same
Definition: Templates.hpp:125
static constexpr std::size_t size(void) noexcept
The size of the integer pack.
Definition: Templates.hpp:72
typename unwrap_refwrapper< typename std::decay< T >::type >::type special_decay_t
Definition: Templates.hpp:51
T value_type
The type of each integer.
Definition: Templates.hpp:69
T type
the input type of non-reference wrappers
Definition: Templates.hpp:33
Definition: Templates.hpp:31