SUNphi  1.0
TupleWrap.hpp
Go to the documentation of this file.
1 #ifndef _TUPLEWRAP_HPP
2 #define _TUPLEWRAP_HPP
3 
4 /// \file TupleWrap.hpp
5 ///
6 /// \brief Take a Tuple or a single type and returns a Tuple
7 
8 #include <tuple/TupleClass.hpp>
9 
10 namespace SUNphi
11 {
12  /// Wraps a simple type into a \c Tuple containing the type
13  ///
14  /// For a generic type, put the type into a simple \c Tuple, so that
15  /// it can be treated homogeneously with other Tuples in
16  /// e.g. \c TupleTypeCatT
17  ///
18  /// Example:
19  /// \code
20  /// typename TupleWrap<int>::type test; //Tuple<int>
21  /// \endcode
22  template <class T>
23  struct _TupleWrap
24  {
25  /// Internal mapped type
26  typedef Tuple<T> type;
27  };
28 
29  /// Remap a \c Tuple type into itself
30  ///
31  /// Defines a type equal to the Tuple passed as a parameter.
32  ///
33  /// Example:
34  /// \code
35  /// typename TupleWrap<Tuple<int>>::type test; //Tuple<int>
36  /// \endcode
37  template <class...T>
38  struct _TupleWrap<Tuple<T...>>
39  {
40  /// Internal mapped type
41  typedef Tuple<T...> type;
42  };
43 
44  /// Put the type into a \c Tuple, if the type is not already a \c Tuple.
45  ///
46  /// The following situations are possible:
47  ///
48  /// \li A non-Tuple type \c T is put inside a \c Tuple<T>
49  ///
50  /// \li A \c Tuple<T> is mapped to itself
51  ///
52  /// Example:
53  /// \code
54  /// TupleWrap<int> test1; //sTuple<int>
55  /// TupleWrap<Tuple<int>> test2; //Tuple<int>
56  /// \endcode
57  template <class T>
58  using TupleWrap=typename _TupleWrap<T>::type;
59 }
60 
61 #endif
Tuple< T > type
Internal mapped type.
Definition: TupleWrap.hpp:26