]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lld/Core/STDExtras.h
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / include / lld / Core / STDExtras.h
1 //===- lld/Core/STDExtra.h - Helpers for the stdlib -----------------------===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLD_CORE_STD_EXTRA_H
11 #define LLD_CORE_STD_EXTRA_H
12
13 namespace lld {
14 /// \brief Deleter for smart pointers that only calls the destructor. Memory is
15 /// managed elsewhere. A common use of this is for things allocated with a
16 /// BumpPtrAllocator.
17 template <class T>
18 struct destruct_delete {
19   void operator ()(T *ptr) {
20     ptr->~T();
21   }
22 };
23
24 template <class T>
25 using unique_bump_ptr = std::unique_ptr<T, destruct_delete<T>>;
26
27 } // end namespace lld
28
29 #endif