blob: b7ccd1801ffaff4f1eb746a29f336570b83bcd44 (
plain)
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
|
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Marc Glisse
*
* Copyright (C) 2015 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#ifndef ALLOCATOR_H_
#define ALLOCATOR_H_
#include <memory>
#include <utility>
namespace Gudhi {
/** \private
* An allocator that can be used to build an uninitialized vector.
*/
template <class T, class Base = std::allocator<T>>
struct no_init_allocator : Base {
typedef std::allocator_traits<Base> Base_traits;
template <class U> struct rebind {
typedef no_init_allocator<U, typename Base_traits::template rebind_alloc<U>> other;
};
// Inherit constructors.
using Base::Base;
// Do nothing: that's the whole point!
template<class P>
void construct(P*) noexcept {}
template<class P, class...U> void construct(P*p, U&&...u) {
Base_traits::construct(*(Base*)this, p, std::forward<U>(u)...);
}
};
} // namespace Gudhi
#endif // ALLOCATOR_H_
|