Skip to content

Class cfor_t

class cfor_t<stop, start, conditional> meta

template <size_t stop, size_t start, bool conditional = false>
struct cfor_t { … }

Compile-time for loop helper that unrolls iteration over [start, stop) .

Template parameters
stop past-the-last index (exclusive)
start first index (inclusive, default 0)
conditional if true , stop on the first falsy body result
// `i` is a compile-time constant inside the body; the loop is unrolled.
 // Note: a semicolon is required after the closing brace (unlike a regular
 // for loop), because the macro expands to an assignment expression.
 KFR_FOR(i, 0, 3)
 {
     constexpr size_t j = i;
     std::printf("%zu\n", j);  // prints 0, 1, 2
 };

 // Conditional: stops at the first index where the body returns false
 KFR_FORC(i, 0, 5)
 {
     return i < 2;  // only i == 0 and i == 1 are processed
 };

function operator=(Fn &&)

template <typename Fn>
constexpr KFR_MEM_INTRINSIC void operator=(Fn&& fn) const { … }

Invokes fn for each index in [start, stop) , passing i as template argument.

Template parameters
Fn body callable; return value is ignored unless conditional is true .

Fully qualified name: kfr::cfor_t<stop, start, conditional>::operator=(Fn &&)

Declared at meta.hpp:1849

Fully qualified name: kfr::cfor_t<stop, start, conditional>

Declared at meta.hpp:1844

This file was generated by cxxdox, a C++ documentation generator based on MkDocs Material and libclang.