basic.hpp 2.28 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
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: 
 * 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.
 * 
 ******************************************************************************/



/** \file basic.hpp */

#ifndef AMDIS_BASIC_TRAITS_HPP
#define AMDIS_BASIC_TRAITS_HPP

#include <boost/version.hpp> 
#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

namespace AMDiS 
{

  // introduce some shortcuts for boost::mpl
  // ---------------------------------------
47
  using boost::mpl::bool_;
48
49
50
51
52
53
  using boost::mpl::true_;
  using boost::mpl::false_;
  using boost::mpl::and_;
  using boost::mpl::or_;
  
  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
62
63
  
  namespace traits 
  {
  
    // dummy type
    typedef boost::numeric::ublas::error_cant_deduce_type no_valid_type;
  
64
65
66
67
68
69
70
71
72
    template <class A, class B>
    struct is_multiplicable : boost::mpl::not_< 
	boost::is_same< typename mtl::Multiplicable<A,B>::result_type, 
		        no_valid_type > > {};
  
    template <class A, class B>
    struct is_addable : boost::mpl::not_< 
	boost::is_same< typename mtl::Addable<A,B>::result_type, 
			no_valid_type > > {};
73
74
75
76
77
78
79
80
81
      
#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
    
82
83
    template <class T, T A, T B>
    struct equal : boost::mpl::if_c< A == B, true_, false_ > {};
84
  }
85
86
87
  
//   template <class T> 
//   T zero(T result) { result = 0; return result; }
88
89
90
91
}


#endif // AMDIS_BASIC_TRAITS_HPP