Callable object checking if a product type contains a given identifier.
#include <kumi/algorithm/contains.hpp>
template<product_type T, identifier ID>
constexpr auto contains(T && t, ID
const&
id)
noexcept;
constexpr contains_t contains
Callable object checking if a product type contains a given identifier.
Definition contains.hpp:125
- t: The product type to inspect
- id: The identifier to check for
- std::true_type if t contains a field labeled with the id identifier, std::false_type otherwise.
template<kumi::concepts::product_type T, kumi::concepts::
identifier ID>
struct contains
{
using type =
decltype(
kumi::contains(std::declval<T>(), std::declval<ID>()));
};
template<kumi::concepts::product_type T, kumi::concepts::identifier ID>
using contains_t = typename kumi::result::contains<T, ID>::type;
Computes the return type of a call to kumi:contains:
#include <kumi/kumi.hpp>
#include <iostream>
using namespace kumi::literals;
template<kumi::concepts::product_type T>
void check_contains(T const& t)
{
std::cout <<
"Correct product_type: " <<
get<
"value"_id>(t) <<
'\n';
else
std::cout << "Incorrect product type\n";
}
int main()
{
check_contains(
kumi::tuple{
"malus"_id = 6.5,
"value"_id = 17} );
}
decltype(auto) constexpr get(record< Ts... > &r) noexcept
Extracts the Ith field from a kumi::record.
Definition record.hpp:618
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33
#include <kumi/kumi.hpp>
#include <iostream>
using namespace kumi::literals;
template<kumi::concepts::product_type T>
void check_contains(T const& t)
{
std::cout <<
"Correct product_type: " <<
get<
"value"_id>(t) <<
'\n';
else
std::cout << "Incorrect product type\n";
}
int main()
{
check_contains(
kumi::record{
"malus"_id = 6.5,
"value"_id = 17} );
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36