template<typename T>
struct kumi::is_product_type< T >
Detects if a type follows the tuple protocol.
To be treated like a product_type, a user defined type must follow the tuple protocol defined in the standard.
Helper value
Detects if a type follows the tuple protocol.
Definition traits.hpp:71
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;
}
}
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};
{
std::cout << "# " << i
<< " : " << e
<< "\n";
}
, peter
);
}
constexpr decltype(auto) get(record< Ts... > &&r) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition record.hpp:410