Loading [MathJax]/extensions/tex2jax.js
kumi v3.1.0
Exquisite Epidote
 
All Classes Namespaces Functions Variables Friends Modules Pages Concepts
Loading...
Searching...
No Matches

◆ locate()

template<typename Pred , typename... Ts>
constexpr auto kumi::locate ( tuple< Ts... > const t,
Pred  p 
)
constexprnoexcept

Return the index of a value which type satisfies a given predicate.

Parameters
tTuple to process
pUnary predicate. p must return a value convertible to bool for every element of t.
Returns
Integral index of the element inside the tuple if present, kumi::size<tuple<T...>>::value otherwise.

Example:

#include <kumi/tuple.hpp>
#include <iostream>
#include <type_traits>
int main()
{
auto t = kumi::tuple{1, 2., 0ULL, 3.f, 'z'};
std::cout << std::boolalpha
std::cout << std::boolalpha << kumi::locate( t, [](auto e) { return e > 3; } ) << "\n";
}
constexpr auto locate(tuple< Ts... > const &t, Pred p) noexcept
Return the index of a value which type satisfies a given predicate.
Definition find.hpp:23
constexpr auto from_tuple(tuple< Ts... > const &t)
Converts a kumi::tuple to an instance of an arbitrary type.
Definition convert.hpp:59
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:35