Loading...
Searching...
No Matches
Namespaces | Functions
enumerate.h File Reference

Enumerate all elements in iterators recursively. More...

#include <concepts>
#include "concepts/util.h"

Go to the source code of this file.

Namespaces

namespace  bbm
 

Functions

template<typename VALUE , typename T , typename CALLBACK >
requires (std::convertible_to<T&, VALUE> && std::invocable<CALLBACK, VALUE>)
void enumerate (T &&value, CALLBACK &&callback)
 Convertible to VALUE => callback.
 
template<typename VALUE , typename T , typename CALLBACK >
requires (std::ranges::range<T> && !std::convertible_to<T&, VALUE> && std::invocable<CALLBACK, VALUE>)
void enumerate (T &&obj, CALLBACK &&callback)
 iterable object => enumerate(begin(), ..., end())
 

is_enumerable

template<typename VALUE , typename T >
using is_enumerable = bbm::detail::is_enumerable_impl< VALUE, T >
 
template<typename VALUE , typename T >
constexpr bool is_enumerable_v = is_enumerable<VALUE,T>::value
 

Detailed Description

Enumerate all elements in iterators recursively.

Enumerate all elements of in an iterable type recursively until the element can be cast to a given VALUE type. The value is than passed into a provided callback function:

enumerate<float>(data, [&](auto& val) { some_vector.push_back(val); });

will enumerate all elements in data, and push them onto 'some_vector'.