mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
macro.hpp File Reference
#include <boost/preprocessor/seq/for_each.hpp>
#include <cstdlib>
#include <initializer_list>
#include <iostream>
#include <memory>
Include dependency graph for macro.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  m
 

‍mutable namespace


 

Macros

#define M_ID(X)   X
 
#define M_CAT(X, Y)   M_CAT_(X, Y)
 
#define M_CAT_(X, Y)   X ## Y
 
#define M_EMPTY()
 
#define M_DEFER1(X)   X M_EMPTY()
 
#define M_COMMA(X)   X,
 
#define M_COMMA_PRE(X)   ,X
 
#define M_UNPACK(...)   __VA_ARGS__
 
#define M_EVAL(...)   M_EVAL1(M_EVAL1(M_EVAL1(__VA_ARGS__)))
 
#define M_EVAL1(...)   M_EVAL2(M_EVAL2(M_EVAL2(__VA_ARGS__)))
 
#define M_EVAL2(...)   M_EVAL3(M_EVAL3(M_EVAL3(__VA_ARGS__)))
 
#define M_EVAL3(...)   M_EVAL4(M_EVAL4(M_EVAL4(__VA_ARGS__)))
 
#define M_EVAL4(...)   M_EVAL5(M_EVAL5(M_EVAL5(__VA_ARGS__)))
 
#define M_EVAL5(...)   __VA_ARGS__
 
#define M_STR_(X)   #X
 
#define M_STR(X)   M_STR_(X)
 
#define M_STRCOMMA(X)   M_STR(X),
 
#define M_PASTE_(X, Y)   X ## Y
 
#define M_PASTE(X, Y)   M_PASTE_(X, Y)
 
#define M_PAIR_FIRST(A, B)   A
 
#define M_PAIR_SECOND(A, B)   B
 
#define M_HEAD(X, ...)   X
 
#define M_TAIL(X, ...)   __VA_ARGS__
 
#define M_COUNT(LIST)   (std::initializer_list<const char*>{ LIST(M_STRCOMMA) }.size())
 
#define M_CONSTEXPR_COND(COND, IF_TRUE, IF_FALSE)
 
#define M_CONSTEXPR_COND_UNCAPTURED(COND, IF_TRUE, IF_FALSE)
 
#define M_PAIR_XFORM_MACRO_(_, PAIR, ELEM)    M_PAIR_FIRST PAIR ( M_PAIR_SECOND PAIR (ELEM) )
 
#define M_PAIR_XFORM_(PAIR, SEQ)    BOOST_PP_SEQ_FOR_EACH(M_PAIR_XFORM_MACRO_, PAIR, SEQ)
 
#define M_TRANSFORM_X_MACRO(X, SEQ, FUNC)   M_PAIR_XFORM_((X, FUNC), SEQ())
 
#define M_DECLARE_ENUM(LIST)
 
#define M_ENUM_TO_STR(LIST)   LIST(M_STRCOMMA)
 
#define M_DECL(NAME, TYPE)   TYPE NAME;
 
#define M_ARR_SIZE(ARR)   (sizeof(ARR) / sizeof(*(ARR)))
 
#define M_DEBUG(MSG)
 
#define M_LCOV_EXCL_START   /* Start exclusion block */
 
#define M_LCOV_EXCL_STOP   /* Stop exclusion block */
 
#define M_LCOV_EXCL_LINE   /* Exclude line */
 
#define M_NOINLINE   __attribute__((noinline))
 
#define M_INSIST2_(COND, MSG)   ::m::_insist((COND), __FILE__, __LINE__, #COND, MSG)
 
#define M_INSIST1_(COND)   M_INSIST2_(COND, nullptr)
 
#define M_GET_INSIST_(_1, _2, NAME, ...)   NAME
 
#define M_insist(...)   M_GET_INSIST_(__VA_ARGS__, M_INSIST2_, M_INSIST1_, XXX)(__VA_ARGS__)
 
#define M_unreachable(MSG)   m::_abort(__FILE__, __LINE__, (MSG))
 
#define M_notnull(ARG)   m::_notnull((ARG), __FILE__, __LINE__, #ARG)
 
#define M_nothrow(ARG)
 
#define M_DISCARD   (void)
 

Functions

void m::_insist (const bool cond, const char *filename, const unsigned line, const char *condstr, const char *msg)
 
void m::_abort (const char *filename, const unsigned line, const char *msg)
 
template<typename T >
T * m::_notnull (T *arg, const char *filename, const unsigned line, const char *argstr)
 
template<typename T >
std::unique_ptr< T > m::_notnull (std::unique_ptr< T > arg, const char *filename, const unsigned line, const char *argstr)
 

Macro Definition Documentation

◆ M_ARR_SIZE

#define M_ARR_SIZE (   ARR)    (sizeof(ARR) / sizeof(*(ARR)))

Definition at line 79 of file macro.hpp.

◆ M_CAT

#define M_CAT (   X,
 
)    M_CAT_(X, Y)

Definition at line 19 of file macro.hpp.

◆ M_CAT_

#define M_CAT_ (   X,
 
)    X ## Y

Definition at line 20 of file macro.hpp.

◆ M_COMMA

#define M_COMMA (   X)    X,

Definition at line 23 of file macro.hpp.

◆ M_COMMA_PRE

#define M_COMMA_PRE (   X)    ,X

Definition at line 24 of file macro.hpp.

◆ M_CONSTEXPR_COND

#define M_CONSTEXPR_COND (   COND,
  IF_TRUE,
  IF_FALSE 
)
Value:
[&](){ \
if constexpr (COND) { return (IF_TRUE); } else { return (IF_FALSE); } \
}()

Definition at line 54 of file macro.hpp.

◆ M_CONSTEXPR_COND_UNCAPTURED

#define M_CONSTEXPR_COND_UNCAPTURED (   COND,
  IF_TRUE,
  IF_FALSE 
)
Value:
[](){ \
if constexpr (COND) { return (IF_TRUE); } else { return (IF_FALSE); } \
}()

Definition at line 57 of file macro.hpp.

◆ M_COUNT

#define M_COUNT (   LIST)    (std::initializer_list<const char*>{ LIST(M_STRCOMMA) }.size())

Definition at line 51 of file macro.hpp.

◆ M_DEBUG

#define M_DEBUG (   MSG)
Value:
std::cout.flush(); \
std::cerr << __FILE__ << ':' << __LINE__ << ": " << __FUNCTION__ << ' ' << MSG << std::endl

Definition at line 83 of file macro.hpp.

◆ M_DECL

#define M_DECL (   NAME,
  TYPE 
)    TYPE NAME;

Definition at line 76 of file macro.hpp.

◆ M_DECLARE_ENUM

#define M_DECLARE_ENUM (   LIST)
Value:
enum LIST { \
LIST(M_COMMA) \
LIST##_MAX = M_COUNT(LIST) - 1U /* MAX takes the same value as the last *real* enum value */ \
}
#define M_COMMA(X)
Definition: macro.hpp:23
#define M_COUNT(LIST)
Definition: macro.hpp:51

Definition at line 70 of file macro.hpp.

◆ M_DEFER1

#define M_DEFER1 (   X)    X M_EMPTY()

Definition at line 22 of file macro.hpp.

◆ M_DISCARD

#define M_DISCARD   (void)

Definition at line 213 of file macro.hpp.

◆ M_EMPTY

#define M_EMPTY ( )

Definition at line 21 of file macro.hpp.

◆ M_ENUM_TO_STR

#define M_ENUM_TO_STR (   LIST)    LIST(M_STRCOMMA)

Definition at line 75 of file macro.hpp.

◆ M_EVAL

#define M_EVAL (   ...)    M_EVAL1(M_EVAL1(M_EVAL1(__VA_ARGS__)))

Definition at line 27 of file macro.hpp.

◆ M_EVAL1

#define M_EVAL1 (   ...)    M_EVAL2(M_EVAL2(M_EVAL2(__VA_ARGS__)))

Definition at line 28 of file macro.hpp.

◆ M_EVAL2

#define M_EVAL2 (   ...)    M_EVAL3(M_EVAL3(M_EVAL3(__VA_ARGS__)))

Definition at line 29 of file macro.hpp.

◆ M_EVAL3

#define M_EVAL3 (   ...)    M_EVAL4(M_EVAL4(M_EVAL4(__VA_ARGS__)))

Definition at line 30 of file macro.hpp.

◆ M_EVAL4

#define M_EVAL4 (   ...)    M_EVAL5(M_EVAL5(M_EVAL5(__VA_ARGS__)))

Definition at line 31 of file macro.hpp.

◆ M_EVAL5

#define M_EVAL5 (   ...)    __VA_ARGS__

Definition at line 32 of file macro.hpp.

◆ M_GET_INSIST_

#define M_GET_INSIST_ (   _1,
  _2,
  NAME,
  ... 
)    NAME

Definition at line 128 of file macro.hpp.

◆ M_HEAD

#define M_HEAD (   X,
  ... 
)    X

Definition at line 47 of file macro.hpp.

◆ M_ID

#define M_ID (   X)    X

Definition at line 18 of file macro.hpp.

◆ M_insist

#define M_insist (   ...)    M_GET_INSIST_(__VA_ARGS__, M_INSIST2_, M_INSIST1_, XXX)(__VA_ARGS__)

Definition at line 129 of file macro.hpp.

◆ M_INSIST1_

#define M_INSIST1_ (   COND)    M_INSIST2_(COND, nullptr)

Definition at line 120 of file macro.hpp.

◆ M_INSIST2_

#define M_INSIST2_ (   COND,
  MSG 
)    ::m::_insist((COND), __FILE__, __LINE__, #COND, MSG)

Definition at line 119 of file macro.hpp.

◆ M_LCOV_EXCL_LINE

#define M_LCOV_EXCL_LINE   /* Exclude line */

Definition at line 93 of file macro.hpp.

◆ M_LCOV_EXCL_START

#define M_LCOV_EXCL_START   /* Start exclusion block */

Definition at line 91 of file macro.hpp.

◆ M_LCOV_EXCL_STOP

#define M_LCOV_EXCL_STOP   /* Stop exclusion block */

Definition at line 92 of file macro.hpp.

◆ M_NOINLINE

#define M_NOINLINE   __attribute__((noinline))

Definition at line 96 of file macro.hpp.

◆ M_nothrow

#define M_nothrow (   ARG)
Value:
[&](){ \
try { \
return (ARG); \
} catch (const std::exception &e) { \
std::cout.flush(); \
std::cerr << __FILE__ << ':' << __LINE__ << ": " << #ARG << " has thrown exception '" << e.what() << "'" \
<< std::endl; \
abort(); \
} \
}()

Definition at line 197 of file macro.hpp.

◆ M_notnull

#define M_notnull (   ARG)    m::_notnull((ARG), __FILE__, __LINE__, #ARG)

Definition at line 182 of file macro.hpp.

◆ M_PAIR_FIRST

#define M_PAIR_FIRST (   A,
 
)    A

Definition at line 43 of file macro.hpp.

◆ M_PAIR_SECOND

#define M_PAIR_SECOND (   A,
 
)    B

Definition at line 44 of file macro.hpp.

◆ M_PAIR_XFORM_

#define M_PAIR_XFORM_ (   PAIR,
  SEQ 
)     BOOST_PP_SEQ_FOR_EACH(M_PAIR_XFORM_MACRO_, PAIR, SEQ)

Definition at line 64 of file macro.hpp.

◆ M_PAIR_XFORM_MACRO_

#define M_PAIR_XFORM_MACRO_ (   _,
  PAIR,
  ELEM 
)     M_PAIR_FIRST PAIR ( M_PAIR_SECOND PAIR (ELEM) )

Definition at line 62 of file macro.hpp.

◆ M_PASTE

#define M_PASTE (   X,
 
)    M_PASTE_(X, Y)

Definition at line 40 of file macro.hpp.

◆ M_PASTE_

#define M_PASTE_ (   X,
 
)    X ## Y

Definition at line 39 of file macro.hpp.

◆ M_STR

#define M_STR (   X)    M_STR_(X)

Definition at line 36 of file macro.hpp.

◆ M_STR_

#define M_STR_ (   X)    #X

Definition at line 35 of file macro.hpp.

◆ M_STRCOMMA

#define M_STRCOMMA (   X)    M_STR(X),

Definition at line 37 of file macro.hpp.

◆ M_TAIL

#define M_TAIL (   X,
  ... 
)    __VA_ARGS__

Definition at line 48 of file macro.hpp.

◆ M_TRANSFORM_X_MACRO

#define M_TRANSFORM_X_MACRO (   X,
  SEQ,
  FUNC 
)    M_PAIR_XFORM_((X, FUNC), SEQ())

Definition at line 67 of file macro.hpp.

◆ M_UNPACK

#define M_UNPACK (   ...)    __VA_ARGS__

Definition at line 25 of file macro.hpp.

◆ M_unreachable

#define M_unreachable (   MSG)    m::_abort(__FILE__, __LINE__, (MSG))

Definition at line 146 of file macro.hpp.