7#include <dune/common/shared_ptr.hh>
9#include <amdis/common/TypeTraits.hpp>
22 std::shared_ptr<T> wrap_or_share(T& t)
24 return Dune::stackobject_to_shared_ptr(t);
28 std::shared_ptr<T> wrap_or_share(T&& t)
30 return std::make_shared<T>(FWD(t));
34 std::shared_ptr<T> wrap_or_share(T* t)
36 static_assert(not std::is_pointer_v<T*>,
37 "Raw pointers must be wrapped into smart pointers or references to clarify ownership");
41 std::shared_ptr<T> wrap_or_share(std::shared_ptr<T> t)
47 std::shared_ptr<T> wrap_or_share(std::unique_ptr<T> t)
49 return std::shared_ptr<T>(std::move(t));