Yume
Public Member Functions | List of all members
yume::ast::OptionalAnyBase< T > Class Template Reference

Represents "any" kind of ast node of type T, or the absence of one. See OptionalExpr and OptionalType. More...

#include <ast.hpp>

Inheritance diagram for yume::ast::OptionalAnyBase< T >:
Inheritance graph
[legend]

Public Member Functions

 OptionalAnyBase ()
 
 OptionalAnyBase (T *raw_ptr)
 
template<std::convertible_to< unique_ptr< T > > U>
 OptionalAnyBase (U uptr)
 
 OptionalAnyBase (std::nullopt_t)
 
 OptionalAnyBase (optional< unique_ptr< T > > opt_uptr)
 
auto operator-> () const -> const T *
 
auto operator* () const -> const T &
 
auto operator-> () -> T *
 
auto operator* () -> T &
 
 operator bool () const
 
auto has_value () const -> bool
 
auto raw_ptr () const -> const T *
 
auto raw_ptr () -> T *
 

Detailed Description

template<typename T>
class yume::ast::OptionalAnyBase< T >

Represents "any" kind of ast node of type T, or the absence of one. See OptionalExpr and OptionalType.

This template exists to avoid passing around unique_ptr<T>s around in code that deals with AST nodes containing other generic nodes, such as Compound. This class has the exact same layout at AnyBase, but is nominally explicit in its semantics, in that it may be null. It replaces the earlier usages of optional<unique_ptr<T>> which in theory wastes memory for the "optional" part when a nullptr already expresses the desired semantics. Unlike AnyBase, this class does not perform null pointer checks, and may be default constructed, or constructed from a nullptr.

Definition at line 154 of file ast.hpp.

Constructor & Destructor Documentation

◆ OptionalAnyBase() [1/5]

template<typename T >
yume::ast::OptionalAnyBase< T >::OptionalAnyBase ( )
inline

Definition at line 159 of file ast.hpp.

◆ OptionalAnyBase() [2/5]

template<typename T >
yume::ast::OptionalAnyBase< T >::OptionalAnyBase ( T *  raw_ptr)
inlineexplicit

Definition at line 160 of file ast.hpp.

◆ OptionalAnyBase() [3/5]

template<typename T >
template<std::convertible_to< unique_ptr< T > > U>
yume::ast::OptionalAnyBase< T >::OptionalAnyBase ( uptr)
inline

Definition at line 161 of file ast.hpp.

◆ OptionalAnyBase() [4/5]

template<typename T >
yume::ast::OptionalAnyBase< T >::OptionalAnyBase ( std::nullopt_t  )
inline

Definition at line 162 of file ast.hpp.

◆ OptionalAnyBase() [5/5]

template<typename T >
yume::ast::OptionalAnyBase< T >::OptionalAnyBase ( optional< unique_ptr< T > >  opt_uptr)
inlineexplicit

Definition at line 163 of file ast.hpp.

Member Function Documentation

◆ has_value()

template<typename T >
auto yume::ast::OptionalAnyBase< T >::has_value ( ) const -> bool
inline

◆ operator bool()

template<typename T >
yume::ast::OptionalAnyBase< T >::operator bool ( ) const
inline

Definition at line 171 of file ast.hpp.

◆ operator*() [1/2]

template<typename T >
auto yume::ast::OptionalAnyBase< T >::operator* ( ) -> T&
inline

Definition at line 169 of file ast.hpp.

◆ operator*() [2/2]

template<typename T >
auto yume::ast::OptionalAnyBase< T >::operator* ( ) const -> const T&
inline

Definition at line 167 of file ast.hpp.

◆ operator->() [1/2]

template<typename T >
auto yume::ast::OptionalAnyBase< T >::operator-> ( ) -> T*
inline

Definition at line 168 of file ast.hpp.

◆ operator->() [2/2]

template<typename T >
auto yume::ast::OptionalAnyBase< T >::operator-> ( ) const -> const T*
inline

Definition at line 166 of file ast.hpp.

◆ raw_ptr() [1/2]

template<typename T >
auto yume::ast::OptionalAnyBase< T >::raw_ptr ( ) -> T*
inline

Definition at line 174 of file ast.hpp.

◆ raw_ptr() [2/2]

template<typename T >
auto yume::ast::OptionalAnyBase< T >::raw_ptr ( ) const -> const T*
inline

Definition at line 173 of file ast.hpp.

Referenced by yume::semantic::TypeWalker::statement(), and yume::Compiler::statement().


The documentation for this class was generated from the following file: