lokinet/llarp/util/copy_or_nullptr.hpp

14 lines
293 B
C++
Raw Normal View History

2019-05-03 13:15:03 +00:00
#ifndef LLARP_UTIL_COPY_OR_NULLPTR_HPP
#define LLARP_UTIL_COPY_OR_NULLPTR_HPP
#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;
}
#endif