Dune Core Modules (unstable)

Dune::CopyableOptional< Type > Class Template Reference

A copyable type wrapper that provides copy/move assignment operations for types that are only copy/move constructible. More...

#include <dune/common/copyableoptional.hh>

Public Member Functions

template<class T = Type, std::enable_if_t< std::is_default_constructible_v< T >, int > = 0>
constexpr CopyableOptional () noexcept(std::is_nothrow_default_constructible_v< T >)
 Implementation of a default constructor, if the Type is itself default constructible. The internal optional contains a value-initialized Type.
 
template<class T = Type, disableCopyMove< CopyableOptional, T > = 0, std::enable_if_t< std::is_constructible_v< Type, T && >, int > = 0, std::enable_if_t< std::is_convertible_v< T &&, Type >, int > = 0>
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 resolution if T is implicitly convertible to Type.
 
template<class T = Type, disableCopyMove< CopyableOptional, T > = 0, std::enable_if_t< std::is_constructible_v< Type, T && >, int > = 0, std::enable_if_t< not std::is_convertible_v< T &&, Type >, int > = 0>
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 resolution if T is not implicitly convertible to Type.
 
template<class... Args, disableCopyMove< CopyableOptional, Args... > = 0, std::enable_if_t<(sizeof...(Args) > 1), int > = 0, std::enable_if_t< std::is_constructible_v< Type, Args &&... >, int > = 0>
constexpr CopyableOptional (Args &&... args) noexcept(std::is_nothrow_constructible_v< Type, Args &&... >)
 Construct the internal data from perfect forwarding of the passed arguments.
 
constexpr CopyableOptional (const CopyableOptional &)=default
 Copy construct the contained value.
 
constexpr CopyableOptional (CopyableOptional &&)=default
 Move construct the contained value.
 
 ~CopyableOptional ()=default
 Default destructor.
 
constexpr CopyableOptionaloperator= (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.
 
template<class T = Type, std::enable_if_t< std::is_move_constructible_v< T >, int > = 0>
constexpr CopyableOptionaloperator= (CopyableOptional &&that) noexcept(std::is_nothrow_move_assignable_v< Type >||(!std::is_move_assignable_v< Type > &&std::is_nothrow_move_constructible_v< Type >))
 Move assignment in terms of move constructor.
 
template<class T = Type, std::enable_if_t< not std::is_same_v< std::decay_t< T >, CopyableOptional >, int > = 0, std::enable_if_t<(std::is_assignable_v< Type &, T >||std::is_constructible_v< Type, T >), int > = 0>
constexpr CopyableOptionaloperator= (T &&value) noexcept(std::is_nothrow_assignable_v< Type &, T >||(!std::is_assignable_v< Type &, T > &&std::is_nothrow_constructible_v< Type, T >))
 Perfect-forwarded assignment or construction.
 

Detailed Description

template<class Type>
class Dune::CopyableOptional< Type >

A copyable type wrapper that provides copy/move assignment operations for types that are only copy/move constructible.

Some types, like lambdas, LocalFiniteElementCache, Geometries,... provide a copy/move constructor but do not provide a corresponding assignment operator. Mostly, the assignment operators can be implemented in terms of the corresponding constructors. This type wrapper provides these assignment operators by internally wrapping the type into a std::optional.

Template Parameters
TypeThe type to be wrapped and equipped with copy operations.

Requirements: Type must be an object type that is copy-constructible


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (Apr 25, 22:37, 2024)