Reference documentation for deal.II version 8.4.2
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 }
37 DEAL_II_NAMESPACE_CLOSE
38 
39 #else
40 
41 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
42 #include <boost/type_traits.hpp>
43 #include <boost/version.hpp>
44 #if BOOST_VERSION<105600
45 #include <boost/utility/enable_if.hpp>
46 #else
47 #include <boost/core/enable_if.hpp>
48 #endif
50 
51 DEAL_II_NAMESPACE_OPEN
52 namespace std_cxx11
53 {
54  using boost::is_fundamental;
55  using boost::is_pod;
56  using boost::is_pointer;
57 
58  // boost::enable_if_c, *not* boost::enable_if, is equivalent to std::enable_if.
59  template <bool B, class T = void>
60  struct enable_if : public boost::enable_if_c<B, T>
61  {};
62 
63  // boost does not have is_standard_layout and
64  // is_trivial, but those are both a subset of
65  // is_pod
66  template <typename T>
67  struct is_standard_layout
68  {
69  static const bool value = boost::is_pod<T>::value;
70  };
71 
72  template <typename T>
73  struct is_trivial
74  {
75  static const bool value = boost::has_trivial_copy<T>::value &&
76  boost::has_trivial_assign<T>::value &&
77  boost::has_trivial_constructor<T>::value &&
78  boost::has_trivial_destructor<T>::value;
79  };
80 }
81 DEAL_II_NAMESPACE_CLOSE
82 
83 #endif
84 
85 
86 // then allow using the old namespace name instead of the new one
87 DEAL_II_NAMESPACE_OPEN
88 namespace std_cxx1x = std_cxx11;
89 DEAL_II_NAMESPACE_CLOSE
90 
91 #endif