TypeTraits.hpp 1.01 KB
Newer Older
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
#pragma once

#include <memory>
#include <type_traits>
#include <vector>

#if AMDIS_HAS_CXX_CONSTEXPR_IF
#define IF_CONSTEXPR if constexpr
#else
#define IF_CONSTEXPR if
#endif

namespace AMDiS
{
  namespace Impl
  {
    template <class T>
    struct UnderlyingType
    {
      using type = T;
    };

    template <class T>
    struct UnderlyingType<std::reference_wrapper<T>>
    {
      using type = T;
    };
  }

  template <class T>
  using Underlying_t = typename Impl::UnderlyingType<T>::type;

  // ---------------------------------------------------------------------------

  /// A variadic type list
  template <class... Ts>
  struct Types {};

  template <class... Ts>
  using Types_t = Types<std::decay_t<Ts>...>;


  /// Alias that indicates ownership of resources
  template <class T>
  using owner = T;


  /// Create a unique_ptr by copy/move construction
  template <class Obj>
  auto makeUniquePtr(Obj&& obj)
  {
    return std::make_unique<std::decay_t<Obj>>(std::forward<Obj>(obj));
  }

} // end namespace AMDiS