Reference documentation for deal.II version 8.5.1
type_traits.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2012 - 2015 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__std_cxx11_type_traits_h
17 #define dealii__std_cxx11_type_traits_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #ifdef DEAL_II_WITH_CXX11
23 
24 # include <type_traits>
25 DEAL_II_NAMESPACE_OPEN
26 namespace std_cxx11
27 {
28  // TODO: could fill up with more types from
29  // C++11 type traits
30  using std::is_fundamental;
31  using std::is_pod;
32  using std::is_pointer;
33  using std::is_standard_layout;
34  using std::is_trivial;
35  using std::enable_if;
36  using std::true_type;
37  using std::false_type;
38 }
39 DEAL_II_NAMESPACE_CLOSE
40 
41 #else
42 
43 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
44 #include <boost/type_traits.hpp>
45 #include <boost/version.hpp>
46 #if BOOST_VERSION<105600
47 #include <boost/utility/enable_if.hpp>
48 #else
49 #include <boost/core/enable_if.hpp>
50 #endif
51 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
52 
53 DEAL_II_NAMESPACE_OPEN
54 namespace std_cxx11
55 {
56  using boost::is_fundamental;
57  using boost::is_pod;
58  using boost::is_pointer;
59 
60  // boost::enable_if_c, *not* boost::enable_if, is equivalent to std::enable_if.
61  template <bool B, class T = void>
62  struct enable_if : public boost::enable_if_c<B, T>
63  {};
64 
65  // boost does not have is_standard_layout and
66  // is_trivial, but those are both a subset of
67  // is_pod
68  template <typename T>
69  struct is_standard_layout
70  {
71  static const bool value = boost::is_pod<T>::value;
72  };
73 
74  template <typename T>
75  struct is_trivial
76  {
77  static const bool value = boost::has_trivial_copy<T>::value &&
78  boost::has_trivial_assign<T>::value &&
79  boost::has_trivial_constructor<T>::value &&
80  boost::has_trivial_destructor<T>::value;
81  };
82 
83  using boost::true_type;
84  using boost::false_type;
85 }
86 DEAL_II_NAMESPACE_CLOSE
87 
88 #endif
89 
90 
91 // then allow using the old namespace name instead of the new one
92 DEAL_II_NAMESPACE_OPEN
93 namespace std_cxx1x = std_cxx11;
94 DEAL_II_NAMESPACE_CLOSE
95 
96 #endif