MLIR  20.0.0git
Public Types | Public Member Functions | List of all members
mlir::python::Defaulting< DerivedTy, T > Class Template Reference

CRTP template for special wrapper types that are allowed to be passed in as 'None' function arguments and can be resolved by some global mechanic if so. More...

#include "Bindings/Python/PybindUtils.h"

+ Inheritance diagram for mlir::python::Defaulting< DerivedTy, T >:

Public Types

using ReferrentTy = T
 

Public Member Functions

 Defaulting ()=default
 Type casters require the type to be default constructible, but using such an instance is illegal. More...
 
 Defaulting (ReferrentTy &referrent)
 
ReferrentTyget () const
 
ReferrentTyoperator-> ()
 

Detailed Description

template<typename DerivedTy, typename T>
class mlir::python::Defaulting< DerivedTy, T >

CRTP template for special wrapper types that are allowed to be passed in as 'None' function arguments and can be resolved by some global mechanic if so.

Such types will raise an error if this global resolution fails, and it is actually illegal for them to ever be unresolved. From a user perspective, they behave like a smart ptr to the underlying type (i.e. 'get' method and operator-> overloaded).

Derived types must provide a method, which is called when an environmental resolution is required. It must raise an exception if resolution fails: static ReferrentTy &resolve()

They must also provide a parameter description that will be used in error messages about mismatched types: static constexpr const char kTypeDescription[] = "<Description>";

Definition at line 39 of file PybindUtils.h.

Member Typedef Documentation

◆ ReferrentTy

template<typename DerivedTy , typename T >
using mlir::python::Defaulting< DerivedTy, T >::ReferrentTy = T

Definition at line 41 of file PybindUtils.h.

Constructor & Destructor Documentation

◆ Defaulting() [1/2]

template<typename DerivedTy , typename T >
mlir::python::Defaulting< DerivedTy, T >::Defaulting ( )
default

Type casters require the type to be default constructible, but using such an instance is illegal.

◆ Defaulting() [2/2]

template<typename DerivedTy , typename T >
mlir::python::Defaulting< DerivedTy, T >::Defaulting ( ReferrentTy referrent)
inline

Definition at line 45 of file PybindUtils.h.

Member Function Documentation

◆ get()

template<typename DerivedTy , typename T >
ReferrentTy* mlir::python::Defaulting< DerivedTy, T >::get ( ) const
inline

Definition at line 47 of file PybindUtils.h.

◆ operator->()

template<typename DerivedTy , typename T >
ReferrentTy* mlir::python::Defaulting< DerivedTy, T >::operator-> ( )
inline

Definition at line 48 of file PybindUtils.h.


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