Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
memory.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2017 - 2020 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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 #ifndef dealii_cxx14_memory_h
16 #define dealii_cxx14_memory_h
17 
18 #include <deal.II/base/config.h>
19 
20 #include <memory>
21 
22 #ifndef DEAL_II_WITH_CXX14
23 // needed for array type check
24 # include <type_traits>
25 #endif
26 
28 
29 namespace std_cxx14
30 {
31 #ifdef DEAL_II_WITH_CXX14
32  using std::make_unique;
33 
34 #else
35 
36  namespace internal
37  {
38  template <typename T>
39  struct is_bounded_array
40  {
41  static constexpr bool value = false;
42  };
43 
44  template <typename T, std::size_t N>
45  struct is_bounded_array<T[N]>
46  {
47  static constexpr bool value = true;
48  };
49  } // namespace internal
50 
51  template <typename T, typename... Args>
52  inline
53  typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
54  make_unique(Args &&... constructor_arguments)
55  {
56  return std::unique_ptr<T>(
57  new T(std::forward<Args>(constructor_arguments)...));
58  }
59 
60  template <typename T>
61  inline
62  typename std::enable_if<std::is_array<T>::value, std::unique_ptr<T>>::type
63  make_unique(std::size_t n)
64  {
66  "This function is not implemented for bounded array types.");
67  return std::unique_ptr<T>(new typename std::remove_extent<T>::type[n]);
68  }
69 
70 #endif
71 } // namespace std_cxx14
72 
74 
75 #endif // dealii_cxx14_memory_h
static const char T
Definition: c++.h:129
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
static const char N
static const bool value