SpECTRE  v2026.11.11
Loading...
Searching...
No Matches
MaybeOwned< T > Class Template Reference

An object or reference. More...

#include <MaybeOwned.hpp>

Public Types

using value_type = T

Public Member Functions

 MaybeOwned (MaybeOwned &&)=default
MaybeOwned & operator= (MaybeOwned &&)=default
 MaybeOwned (const MaybeOwned &)=delete
MaybeOwned & operator= (const MaybeOwned &)=delete
 MaybeOwned ()
 A default constructed MaybeOwned<T> owns a default-constructed T.
 MaybeOwned (std::remove_const_t< T > owned)
 Create an owning object.
 MaybeOwned (const gsl::not_null< T * > unowned)
 Create a non-owning object.
 MaybeOwned (const gsl::not_null< std::remove_const_t< T > * > unowned)
 Create a non-owning object when the previous constructor needs too many implicit conversions.
 MaybeOwned (MaybeOwned< std::remove_const_t< T > > &&other)
 Conversion from MaybeOwned<T> to MaybeOwned<const T>
MaybeOwned & operator= (MaybeOwned< std::remove_const_t< T > > &&other)
 Conversion from MaybeOwned<T> to MaybeOwned<const T>
MaybeOwned & operator= (std::remove_const_t< T > owned)
 Change the object to owning, destroying any previously owned value.
MaybeOwned & operator= (const gsl::not_null< T * > unowned)
 Change the object to non-owning.
bool is_owning () const
std::remove_const_t< T > to_owned () &&
 Get the owned object, or a copy if non-owning.
T & operator* ()
 Access the contained or referenced object.
const T & operator* () const
 Access the contained or referenced object.
T * operator-> ()
 Access the contained or referenced object.
const T * operator-> () const
 Access the contained or referenced object.

Friends

class MaybeOwned< const T >

Detailed Description

template<typename T>
class MaybeOwned< T >

An object or reference.

This class can either store an object or point to a preexisting one, giving uniform access to the two cases.


The documentation for this class was generated from the following file:
  • src/DataStructures/MaybeOwned.hpp