#include <kumi/kumi.hpp>
#include <cstdint>
#include <iostream>
#include <type_traits>
#include <utility>
using namespace kumi::literals;
struct pixel
{
int r, g, b;
};
template<kumi::concepts::identifier auto ID>
decltype(
auto)
get(pixel
const& p)
noexcept
{
if constexpr(ID == "r"_id) return p.r;
if constexpr(ID == "g"_id) return p.g;
if constexpr(ID == "b"_id) return p.b;
}
template<kumi::concepts::identifier auto ID>
decltype(
auto)
get(pixel& p)
noexcept
{
if constexpr(ID == "r"_id) return p.r;
if constexpr(ID == "g"_id) return p.g;
if constexpr(ID == "b"_id) return p.b;
}
template<>
{};
template<>
struct std::tuple_size<pixel> : std::integral_constant<std::size_t,3>
{};
template<> struct std::tuple_element<0,pixel> { using type = kumi::field<kumi::name<"r">, int>; };
template<> struct std::tuple_element<1,pixel> { using type = kumi::field<kumi::name<"g">, int>; };
template<> struct std::tuple_element<2,pixel> { using type = kumi::field<kumi::name<"b">, int>; };
int main()
{
pixel a = { 37, 15, 27 };
std::cout << b << "\n";
}
constexpr auto to_record(Type &&r)
Converts a kumi::record_type to an instance kumi::record.
Definition record.hpp:465
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:506
Opt-in traits for types behaving like a kumi::product_type.
Definition traits.hpp:92