26#ifndef DUMUX_COMMON_OPTIONAL_HH
27#define DUMUX_COMMON_OPTIONAL_HH
31#include <dune/common/typeutilities.hh>
49 template<
class TT, Dune::disableCopyMove<Optional, TT> = 0>
59 p_ =
new (buffer_) T(std::move(other.value()));
67 p_ =
new (buffer_) T(other.
value());
78 template<
class TT, Dune::disableCopyMove<Optional, TT> = 0 >
82 *p_ = std::forward<T>(t);
84 p_ =
new (buffer_) T(std::forward<T>(t));
91 *
this = other.
value();
92 else if (
operator bool())
103 *
this = std::move(other.value());
104 else if (
operator bool())
112 explicit operator bool()
const
127 template<
class... Args >
132 p_ =
new (buffer_) T(std::forward<Args>(args)...);
146 alignas(T)
char buffer_[
sizeof(T)];
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
A wrapper that can either contain an object of T or be empty.
Definition: optional.hh:42
Optional(TT &&t)
Definition: optional.hh:50
~Optional()
Definition: optional.hh:72
Optional & operator=(const Optional &other)
Definition: optional.hh:88
T & value()
Definition: optional.hh:122
Optional & operator=(TT &&t)
Definition: optional.hh:79
Optional & operator=(Optional &&other)
Definition: optional.hh:100
const T & value() const
Definition: optional.hh:117
Optional(const Optional &other)
Definition: optional.hh:64
Optional(Optional &&other)
Definition: optional.hh:56
void emplace(Args &&... args)
Definition: optional.hh:128
Optional()
Definition: optional.hh:45
void release()
Definition: optional.hh:135