Loading...
Searching...
No Matches
Namespaces | Concepts | Macros | Functions
constforeach.h File Reference

Compile-time for each loop. More...

Go to the source code of this file.

Namespaces

namespace  bbm
 

Concepts

concept  bbm::has_constforeach_lambda
 Concept to check if a lambda functions meets the required signature.
 

Macros

#define CONSTFOREACH(ITR_TYPE, TYPE_LIST, ...)   if constexpr (sizeof...(TYPE_LIST) > 0) bbm::constforeach<TYPE_LIST...>( [&]<typename ITR_TYPE>() { __VA_ARGS__ } );
 HELPER MACRO.
 

Functions

template<typename... T, typename F >
requires has_constforeach_lambda<F, T...>
constexpr void constforeach (F &&f)
 constforeach over all typenames in T.
 

Detailed Description

Compile-time for each loop.

Expects the body to passed as a templated lambda that takes the typenames and no arguments.

Example:

constforeach<Ts...>( [&]<typename T>()
{
std::cerr << typestring<T> << std::endl;
});

Prints the typestrings of all typenames in Ts.

A helper macro simplifies the call:

{
std::cerr << typestring<T> << std::endl;
});
#define CONSTFOREACH(ITR_TYPE, TYPE_LIST,...)
HELPER MACRO.
Definition: constforeach.h:53

Macro Definition Documentation

◆ CONSTFOREACH

#define CONSTFOREACH (   ITR_TYPE,
  TYPE_LIST,
  ... 
)    if constexpr (sizeof...(TYPE_LIST) > 0) bbm::constforeach<TYPE_LIST...>( [&]<typename ITR_TYPE>() { __VA_ARGS__ } );

HELPER MACRO.