---
title: llarp/util/copy_or_nullptr.hpp

---

# llarp/util/copy_or_nullptr.hpp



## Functions

|                | Name           |
| -------------- | -------------- |
| template <typename T \> <br>constexpr std::unique_ptr< T > | **[copy_or_nullptr](Files/copy__or__nullptr_8hpp.md#function-copy-or-nullptr)**(const std::unique_ptr< T > & other) |


## Functions Documentation

### function copy_or_nullptr

```cpp
template <typename T >
static constexpr std::unique_ptr< T > copy_or_nullptr(
    const std::unique_ptr< T > & other
)
```




## Source code

```cpp
#pragma once
#include <memory>

template <typename T>
static constexpr std::unique_ptr<T>
copy_or_nullptr(const std::unique_ptr<T>& other)
{
  if (other)
    return std::make_unique<T>(*other);
  return nullptr;
}
```


-------------------------------

Updated on 2023-01-20 at 18:12:19 +0000
