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

Complile-time for loop. More...

Go to the source code of this file.

Namespaces

namespace  bbm
 

Concepts

concept  bbm::has_constfor_lambda
 Concept to check if a lambda function meets the required signature.
 

Macros

#define CONSTFOR(IDX, NUMITR, ...)   bbm::constfor<NUMITR>( [&]<size_t IDX>() { __VA_ARGS__; } );
 HELPER MACRO.
 

Functions

template<typename F , size_t... IDX>
requires (sizeof...(IDX) == 0 || has_constfor_lambda<F>)
constexpr void constfor (F &&f, std::index_sequence< IDX... >)
 constfor given an index sequence of indexes.
 
template<size_t NumItr, typename F >
requires (NumItr == 0 || has_constfor_lambda<F>)
constexpr void constfor (F &&f)
 constfor given the number of iterations
 

Detailed Description

Complile-time for loop.

Expects the body to be passed as a templated lambda that takes a size_t literal as template parameter, and no arguments.

Example:

constfor<4>( []<size_t IDX>()
{
std::cerr << IDX << std::endl;
});

Prints values from 0 to 3.

A helper macro simplifies the call:

CONSTFOR(IDX, 4,
{
std::cerr << IDX << std::endl;
});
#define CONSTFOR(IDX, NUMITR,...)
HELPER MACRO.
Definition: constfor.h:63

Macro Definition Documentation

◆ CONSTFOR

#define CONSTFOR (   IDX,
  NUMITR,
  ... 
)    bbm::constfor<NUMITR>( [&]<size_t IDX>() { __VA_ARGS__; } );

HELPER MACRO.