14#ifndef OR_TOOLS_UTIL_LAZY_MUTABLE_COPY_H_
15#define OR_TOOLS_UTIL_LAZY_MUTABLE_COPY_H_
54 : copy_(
std::make_unique<T>(
std::move(obj))), ptr_(copy_.
get()) {}
65 if (copy_ ==
nullptr && ptr_ !=
nullptr) {
66 copy_ = std::make_unique<T>(*ptr_);
81 if (copy_ ==
nullptr && ptr_ !=
nullptr) {
82 std::unique_ptr<T> result = std::make_unique<T>(*ptr_);
87 return std::move(copy_);
96 const T*
get()
const {
return ptr_; }
111 std::unique_ptr<T> copy_;
112 const T* ptr_ =
nullptr;
LazyMutableCopy(const LazyMutableCopy &)=delete
class LazyMutableCopy< T > & operator=(const LazyMutableCopy< T > &)=delete
T * get_mutable()
This will copy the object if we don't already have ownership.
bool has_ownership() const
const T * operator->() const
LazyMutableCopy(LazyMutableCopy &&)=default
class LazyMutableCopy< T > & operator=(LazyMutableCopy< T > &&)=default
std::unique_ptr< T > copy_or_move_as_unique_ptr() &&
LazyMutableCopy(const T &obj)
const T & operator*() const
In SWIG mode, we don't want anything besides these top-level includes.