diff options
Diffstat (limited to 'include/lld/Core/STDExtras.h')
-rw-r--r-- | include/lld/Core/STDExtras.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/lld/Core/STDExtras.h b/include/lld/Core/STDExtras.h new file mode 100644 index 0000000000000..4a6183891844f --- /dev/null +++ b/include/lld/Core/STDExtras.h @@ -0,0 +1,29 @@ +//===- lld/Core/STDExtra.h - Helpers for the stdlib -----------------------===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLD_CORE_STD_EXTRA_H +#define LLD_CORE_STD_EXTRA_H + +namespace lld { +/// \brief Deleter for smart pointers that only calls the destructor. Memory is +/// managed elsewhere. A common use of this is for things allocated with a +/// BumpPtrAllocator. +template <class T> +struct destruct_delete { + void operator ()(T *ptr) { + ptr->~T(); + } +}; + +template <class T> +using unique_bump_ptr = std::unique_ptr<T, destruct_delete<T>>; + +} // end namespace lld + +#endif |