Template meta programming helpers

Classes

struct  senf::mpl::nil
 Marker class for empty default values etc. More...
 
struct  senf::mpl::rv< n >
 Return-value type used to implement overload selection. More...
 
struct  senf::mpl::take_uint< _ >
 Take an arbitrary unsigned integer template argument. More...
 
struct  senf::mpl::take_int< _ >
 Take an arbitrary integer template argument. More...
 
struct  senf::mpl::take_class< _ >
 Take an arbitrary type template argument. More...
 

Macros

#define SENF_MPL_RV(expr)
 Get return value of overload selector. More...
 
#define SENF_MPL_SLOT_DEF(name, value)
 Define MPL slot. More...
 
#define SENF_MPL_SLOT_SET(name, value)
 Set MPL slot. More...
 
#define SENF_MPL_SLOT_GET(name)
 Get current MPL slot value. More...
 

Detailed Description

Macro Definition Documentation

◆ SENF_MPL_RV

#define SENF_MPL_RV (   expr)

Get return value of overload selector.

Used together with senf::mpl::rv to implement overload selection.

See also
senf::mpl::rv

Definition at line 119 of file mpl.hh.

◆ SENF_MPL_SLOT_DEF

#define SENF_MPL_SLOT_DEF (   name,
  value 
)

Define MPL slot.

The slot macros SENF_MPL_SLOT_DEF(), SENF_MPL_SLOT_SET() and SENF_MPL_SLOT_GET() provide a facility to get the last unsigned integer value assigned to the slot before the current point in the current class.

struct Foo
{
// Define SLOT slot named 'accum' initialized to 0
SENF_MPL_SLOT_DEF(accum, 0);
// Add 2 to 'accum'
// Multiply 'accum' by 3
// Define the result as a constant expression. result is now 6
static unsigned result = SENF_MPL_SLOT_GET(accum);
};

Of course, it does not make sense to use these macros for simple arithmetic as in the example. The SENF_MPL_SLOT macros allow to define macros which pass information from one macro invocation to the next.

Implementation note:
The implementation is based on LINE: We check backwards for a value defined on a previous line. The check is limited to 40 lines backwards.

Definition at line 183 of file mpl.hh.

◆ SENF_MPL_SLOT_GET

#define SENF_MPL_SLOT_GET (   name)

Get current MPL slot value.

See also
SENF_MPL_SLOT_DEF()

Definition at line 213 of file mpl.hh.

◆ SENF_MPL_SLOT_SET

#define SENF_MPL_SLOT_SET (   name,
  value 
)

Set MPL slot.

See also
SENF_MPL_SLOT_DEF()

Definition at line 204 of file mpl.hh.