allocator.h
1 /* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2  * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3  * Author(s): Marc Glisse
4  *
5  * Copyright (C) 2015 Inria
6  *
7  * Modification(s):
8  * - YYYY/MM Author: Description of the modification
9  */
10 
11 #ifndef ALLOCATOR_H_
12 #define ALLOCATOR_H_
13 
14 #include <memory>
15 #include <utility>
16 
17 namespace Gudhi {
18 
22 template <class T, class Base = std::allocator<T>>
23 struct no_init_allocator : Base {
24  typedef std::allocator_traits<Base> Base_traits;
25  template <class U> struct rebind {
26  typedef no_init_allocator<U, typename Base_traits::template rebind_alloc<U>> other;
27  };
28 
29  // Inherit constructors.
30  using Base::Base;
31 
32  // Do nothing: that's the whole point!
33  template<class P>
34  void construct(P*) noexcept {}
35 
36  template<class P, class...U> void construct(P*p, U&&...u) {
37  Base_traits::construct(*(Base*)this, p, std::forward<U>(u)...);
38  }
39 };
40 
41 } // namespace Gudhi
42 
43 #endif // ALLOCATOR_H_
GUDHI  Version 3.1.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Mon Feb 3 2020 20:32:13 for GUDHI by Doxygen 1.8.16