5#ifndef DUNE_COMMON_COPYABLE_OPTIONAL_HH 
    6#define DUNE_COMMON_COPYABLE_OPTIONAL_HH 
   34    : 
public std::optional<Type>
 
   36  static_assert(std::is_copy_constructible_v<Type>);
 
   37  static_assert(std::is_object_v<Type>);
 
   39  using Base = std::optional<Type>;
 
   47  template <
class T = Type,
 
   48    std::enable_if_t<std::is_default_constructible_v<T>, 
int> = 0>
 
   50        noexcept(
std::is_nothrow_default_constructible_v<T>)
 
   58  template <
class T = Type,
 
   59    disableCopyMove<CopyableOptional,T> = 0,
 
   60    std::enable_if_t<std::is_constructible_v<Type,T&&>, 
int> = 0,
 
   61    std::enable_if_t<std::is_convertible_v<T&&,Type>, 
int> = 0>
 
   63        noexcept(std::is_nothrow_constructible_v<Type,T&&>)
 
   64    : Base{std::in_place, std::forward<T>(value)}
 
   71  template <
class T = Type,
 
   72    disableCopyMove<CopyableOptional,T> = 0,
 
   73    std::enable_if_t<std::is_constructible_v<Type,T&&>, 
int> = 0,
 
   74    std::enable_if_t<not std::is_convertible_v<T&&,Type>, 
int> = 0>
 
   76        noexcept(std::is_nothrow_constructible_v<Type,T&&>)
 
   77    : Base{std::in_place, std::forward<T>(value)}
 
   81  template <
class... Args,
 
   83    std::enable_if_t<(
sizeof...(Args) > 1), 
int> = 0,
 
   84    std::enable_if_t<std::is_constructible_v<Type,Args&&...>, 
int> = 0>
 
   86        noexcept(std::is_nothrow_constructible_v<Type,Args&&...>)
 
   87    : Base{std::in_place, std::forward<Args>(args)...}
 
  101        noexcept(std::is_nothrow_copy_assignable_v<Type> ||
 
  102          (!std::is_copy_assignable_v<Type> && std::is_nothrow_copy_constructible_v<Type>))
 
  104    if constexpr(std::is_copy_assignable_v<Type>)
 
  105      Base::operator=(that);
 
  108      if (
this != std::addressof(that)) {
 
  110          Base::emplace(*that);
 
  119  template <
class T = Type,
 
  120    std::enable_if_t<std::is_move_constructible_v<T>, 
int> = 0>
 
  122        noexcept(std::is_nothrow_move_assignable_v<Type> ||
 
  123          (!std::is_move_assignable_v<Type> && std::is_nothrow_move_constructible_v<Type>))
 
  125    if constexpr(std::is_move_assignable_v<Type>)
 
  126      Base::operator=(std::move(that));
 
  129      if (
this != std::addressof(that)) {
 
  131          Base::emplace(std::move(*that));
 
  140  template <
class T = Type,
 
  141    std::enable_if_t<not std::is_same_v<std::decay_t<T>, 
CopyableOptional>, 
int> = 0,
 
  142    std::enable_if_t<(std::is_assignable_v<Type&,T> || std::is_constructible_v<Type,T>), 
int> = 0>
 
  144        noexcept(std::is_nothrow_assignable_v<Type&,T> ||
 
  145          (!std::is_assignable_v<Type&,T> && std::is_nothrow_constructible_v<Type,T>))
 
  147    if constexpr(std::is_assignable_v<Type&,T>)
 
  148      Base::operator=(std::forward<T>(value));
 
  150      Base::emplace(std::forward<T>(value));
 
A copyable type wrapper that provides copy/move assignment operations for types that are only copy/mo...
Definition: copyableoptional.hh:35
 
constexpr CopyableOptional(CopyableOptional &&)=default
Move construct the contained value.
 
constexpr CopyableOptional(T &&value) noexcept(std::is_nothrow_constructible_v< Type, T && >)
Construct the internal data from perfect forwarding of the passed arguments. Participates in overload...
Definition: copyableoptional.hh:62
 
constexpr CopyableOptional & operator=(const CopyableOptional &that) noexcept(std::is_nothrow_copy_assignable_v< Type >||(!std::is_copy_assignable_v< Type > &&std::is_nothrow_copy_constructible_v< Type >))
Copy assignment in terms of copy constructor.
Definition: copyableoptional.hh:100
 
constexpr CopyableOptional() noexcept(std::is_nothrow_default_constructible_v< T >)
Implementation of a default constructor, if the Type is itself default constructible....
Definition: copyableoptional.hh:49
 
constexpr CopyableOptional(const CopyableOptional &)=default
Copy construct the contained value.
 
constexpr CopyableOptional(Args &&... args) noexcept(std::is_nothrow_constructible_v< Type, Args &&... >)
Construct the internal data from perfect forwarding of the passed arguments.
Definition: copyableoptional.hh:85
 
~CopyableOptional()=default
Default destructor.
 
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition: typeutilities.hh:45
 
Dune namespace.
Definition: alignedallocator.hh:13
 
Utilities for type computations, constraining overloads, ...