diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/API/Utils.h | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) |
Notes
Diffstat (limited to 'source/API/Utils.h')
-rw-r--r-- | source/API/Utils.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/API/Utils.h b/source/API/Utils.h new file mode 100644 index 000000000000..b1975e5421dd --- /dev/null +++ b/source/API/Utils.h @@ -0,0 +1,30 @@ +//===-- Utils.h -------------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_API_UTILS_H +#define LLDB_API_UTILS_H + +#include "llvm/ADT/STLExtras.h" +#include <memory> + +namespace lldb_private { + +template <typename T> std::unique_ptr<T> clone(const std::unique_ptr<T> &src) { + if (src) + return llvm::make_unique<T>(*src); + return nullptr; +} + +template <typename T> std::shared_ptr<T> clone(const std::shared_ptr<T> &src) { + if (src) + return std::make_shared<T>(*src); + return nullptr; +} + +} // namespace lldb_private +#endif |