kumi v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches

◆ contains_only()

template<concepts::product_type T, concepts::identifier... Ks>
bool kumi::contains_only ( T && t,
Ks const &... ks )
inlineconstexprnoexcept

Checks if product type contains fields based only on selected identifiers.

Parameters
tthe product type to inspect.
ksKeywords to check
Returns
true if current product_type contains a field based on any of the ks, and false otherwise.

Examples:

#include <kumi/kumi.hpp>
#include <iostream>
using namespace kumi::literals;
template<kumi::concepts::product_type T>
void check_contains(T const&)
{
if constexpr(contains_only(T{}, "value"_id, "active"_id))
std::cout << "Correct product_type\n";
else
std::cout << "Incorrect product type\n";
}
int main()
{
check_contains( kumi::tuple{"value"_id = 9 });
check_contains( kumi::tuple{"malus"_id = 6.5, "value"_id = 17} );
check_contains( kumi::tuple{"active"_id = std::bool_constant<true>{} });
check_contains( kumi::tuple{"active"_id = std::bool_constant<true>{}, "value"_id = 17} );
check_contains( kumi::tuple{"active"_id = std::bool_constant<true>{}, "value"_id = 17, "other"_id = false});
}
constexpr bool contains_only(T &&t, Ks const &... ks) noexcept
Checks if product type contains fields based only on selected identifiers.
Definition contains.hpp:79
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:29
#include <kumi/kumi.hpp>
#include <iostream>
using namespace kumi::literals;
template<kumi::concepts::product_type T>
void check_contains(T const&)
{
if constexpr(contains_only(T{}, "value"_id, "active"_id))
std::cout << "Correct product_type\n";
else
std::cout << "Incorrect product type\n";
}
int main()
{
check_contains( kumi::record{"value"_id = 9 });
check_contains( kumi::record{"malus"_id = 6.5, "value"_id = 17} );
check_contains( kumi::record{"active"_id = std::bool_constant<true>{} });
check_contains( kumi::record{"active"_id = std::bool_constant<true>{}, "value"_id = 17} );
check_contains( kumi::record{"active"_id = std::bool_constant<true>{}, "value"_id = 17, "other"_id = false});
}
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29