tvm
Public Member Functions | List of all members
tvm::WithGroup< ContextType > Class Template Reference

A group of RAII contexts managed together. More...

#include <with.h>

Collaboration diagram for tvm::WithGroup< ContextType >:

Public Member Functions

 WithGroup ()=default
 
 WithGroup (WithGroup &&)=default
 
WithGroupoperator= (WithGroup &&)=default
 
 WithGroup (const WithGroup &)=delete
 
WithGroupoperator= (const WithGroup &)=delete
 
template<typename... Args>
void Emplace (Args &&... args)
 Construct a context and enter its scope. More...
 
size_t size () const
 Number of active contexts in this group. More...
 
 ~WithGroup () noexcept(false)
 Destructor — exits all contexts in reverse order. More...
 

Detailed Description

template<typename ContextType>
class tvm::WithGroup< ContextType >

A group of RAII contexts managed together.

Allows dynamically emplacing multiple context objects that are all exited (in reverse order) when the group is destroyed. ContextType must declare friend class With<ContextType> and provide EnterWithScope() / ExitWithScope() methods.

WithGroup<ConstraintContext> group;
group.Emplace(&analyzer, cond1); // constructs and enters
group.Emplace(&analyzer, cond2); // constructs and enters
// destructor: exits cond2, then cond1
Template Parameters
ContextTypeThe context type with EnterWithScope/ExitWithScope.

Constructor & Destructor Documentation

◆ WithGroup() [1/3]

template<typename ContextType >
tvm::WithGroup< ContextType >::WithGroup ( )
default

◆ WithGroup() [2/3]

template<typename ContextType >
tvm::WithGroup< ContextType >::WithGroup ( WithGroup< ContextType > &&  )
default

◆ WithGroup() [3/3]

template<typename ContextType >
tvm::WithGroup< ContextType >::WithGroup ( const WithGroup< ContextType > &  )
delete

◆ ~WithGroup()

template<typename ContextType >
tvm::WithGroup< ContextType >::~WithGroup ( )
inlinenoexcept

Destructor — exits all contexts in reverse order.

On normal exit: if any ExitWithScope throws, the remaining contexts are still cleaned up, then the first exception is re-thrown.

During stack unwinding: all exceptions are swallowed to avoid std::terminate.

Member Function Documentation

◆ Emplace()

template<typename ContextType >
template<typename... Args>
void tvm::WithGroup< ContextType >::Emplace ( Args &&...  args)
inline

Construct a context and enter its scope.

Parameters
argsArguments forwarded to ContextType constructor.

◆ operator=() [1/2]

template<typename ContextType >
WithGroup& tvm::WithGroup< ContextType >::operator= ( const WithGroup< ContextType > &  )
delete

◆ operator=() [2/2]

template<typename ContextType >
WithGroup& tvm::WithGroup< ContextType >::operator= ( WithGroup< ContextType > &&  )
default

◆ size()

template<typename ContextType >
size_t tvm::WithGroup< ContextType >::size ( ) const
inline

Number of active contexts in this group.


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