basic.hpp 2.29 KB
Newer Older
1
2
3
4
5
6
7
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
8
 * Authors:
9
10
11
12
13
14
15
16
17
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
18
 *
19
20
21
22
23
24
25
26
27
 ******************************************************************************/



/** \file basic.hpp */

#ifndef AMDIS_BASIC_TRAITS_HPP
#define AMDIS_BASIC_TRAITS_HPP

28
#include <boost/version.hpp>
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <boost/mpl/logical.hpp>

#include "boost/numeric/ublas/detail/returntype_deduction.hpp"
#if BOOST_VERSION >= 105600
#include <boost/core/enable_if.hpp>
#else
#include <boost/utility/enable_if.hpp>
#endif

#ifdef HAS_CPP11
#include <type_traits>
#endif

42
namespace AMDiS
43
44
45
46
{

  // introduce some shortcuts for boost::mpl
  // ---------------------------------------
47
  using boost::mpl::bool_;
48
49
50
51
  using boost::mpl::true_;
  using boost::mpl::false_;
  using boost::mpl::and_;
  using boost::mpl::or_;
52

53
  using boost::enable_if;
54
  using boost::enable_if_c;
55
  using boost::disable_if;
56
  using boost::disable_if_c;
57
58
59
60
61

  template <class T>
  struct id {};

  namespace traits
62
  {
63

64
65
    // dummy type
    typedef boost::numeric::ublas::error_cant_deduce_type no_valid_type;
66

67
    template <class A, class B>
68
69
    struct is_multiplicable : boost::mpl::not_<
	boost::is_same< typename mtl::Multiplicable<A,B>::result_type,
70
		        no_valid_type > > {};
71

72
    template <class A, class B>
73
74
    struct is_addable : boost::mpl::not_<
	boost::is_same< typename mtl::Addable<A,B>::result_type,
75
			no_valid_type > > {};
76

77
78
79
80
81
82
83
#ifdef HAS_CPP11
    template <typename T>
    struct is_trivially_copyable : std::is_trivially_copyable<T> {};
#else
    template <typename T>
    struct is_trivially_copyable : boost::is_pod<T> {};
#endif
84

85
86
    template <class T, T A, T B>
    struct equal : boost::mpl::if_c< A == B, true_, false_ > {};
87
  }
88
89

//   template <class T>
90
//   T zero(T result) { result = 0; return result; }
91
92
93
94
}


#endif // AMDIS_BASIC_TRAITS_HPP