FreeTensor
Loading...
Searching...
No Matches
Classes | Namespaces | Macros
maybe_void.h File Reference
#include <type_traits>
#include <variant>
Include dependency graph for maybe_void.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  freetensor::TypeOrMonostate< T >
 
struct  freetensor::TypeOrMonostate< void >
 

Namespaces

namespace  freetensor
 

Macros

#define MAYBE_VOID_ASSIGN(name, expr)
 
#define MAYBE_VOID(name, expr)
 

Macro Definition Documentation

◆ MAYBE_VOID

#define MAYBE_VOID (   name,
  expr 
)
Value:
[[maybe_unused]] typename TypeOrMonostate<decltype(expr)>::type name; \
MAYBE_VOID_ASSIGN(name, expr)

Expand to auto name = expr for normal types, and expand to expr for void

◆ MAYBE_VOID_ASSIGN

#define MAYBE_VOID_ASSIGN (   name,
  expr 
)
Value:
if constexpr (std::is_same_v<decltype(expr), void>) { \
expr; \
} else { \
name = expr; \
}

Expand to name = expr for normal types, and expand to expr for void