KUMI v4.0.0
Flawless Fluorite
Loading...
Searching...
No Matches

◆ is_product_type_v

template<typename T>
bool kumi::is_product_type_v = kumi_implementation_defined
inlineconstexpr

Detects if a type follows the tuple protocol.

Template Parameters
TType to inspect

To be treated like a product_type, a user defined type must follow the tuple protocol defined in the standard.

Helper type-trait

namespace kumi
{
template<typename T> struct is_product_type;
}
Main KUMI namespace.
Definition algorithm.hpp:11

Example:

#include <kumi/kumi.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct people
{
std::string name;
int age;
};
template<std::size_t I>
decltype(auto) get(people const& s) noexcept
{
if constexpr(I==0) return s.name;
if constexpr(I==1) return s.age;
}
template<std::size_t I>
decltype(auto) get(people& s) noexcept
{
if constexpr(I==0) return s.name;
if constexpr(I==1) return s.age;
}
}
// Adapt as structured bindable type
template<>
struct std::tuple_size<ns::people>
: std::integral_constant<std::size_t,2> {};
template<> struct std::tuple_element<0,ns::people> { using type = std::string; };
template<> struct std::tuple_element<1,ns::people> { using type = int; };
int main()
{
ns::people peter{"Peter Parker", 24};
kumi::for_each_index( [](auto i, auto e)
{
std::cout << "# " << i
<< " : " << e
<< "\n";
}
, peter
);
}
Compile-time text based identifier.
Definition identifier.hpp:162
decltype(auto) constexpr get(record< Ts... > &r) noexcept
Extracts the Ith field from a kumi::record.
Definition record.hpp:618