blob: 4201e825c4469e9c433d200bb47fd1653c1e5ac9 [file] [log] [blame]
Jonas Devliegherebd4bf822019-03-06 00:05:55 +00001//===-- Utils.h -------------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
Jonas Devliegherecdc514e2020-02-17 15:57:45 -08009#ifndef LLDB_SOURCE_API_UTILS_H
10#define LLDB_SOURCE_API_UTILS_H
Jonas Devliegherebd4bf822019-03-06 00:05:55 +000011
12#include "llvm/ADT/STLExtras.h"
13#include <memory>
14
15namespace lldb_private {
16
17template <typename T> std::unique_ptr<T> clone(const std::unique_ptr<T> &src) {
18 if (src)
Jonas Devliegherea8f3ae72019-08-14 22:19:23 +000019 return std::make_unique<T>(*src);
Jonas Devliegherebd4bf822019-03-06 00:05:55 +000020 return nullptr;
21}
22
23template <typename T> std::shared_ptr<T> clone(const std::shared_ptr<T> &src) {
24 if (src)
25 return std::make_shared<T>(*src);
26 return nullptr;
27}
28
29} // namespace lldb_private
30#endif